Hi, I am running apache on local pc/ under Windows.
I need to figure out the ip number of the pc inside PHP. This is the
number available when you do ipconfig, and not the 127.0.0.1!
So the slow way I have figured out is to do a system call to doc,
using `ipconfig`, and then regex the result and figure out the ip.
Is there a fater/more efficient way to do this?
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Find-loc...ict131475.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=438714 6 2471
>Hi, I am running apache on local pc/ under Windows. I need to figure out the ip number of the pc inside PHP. This is the number available when you do ipconfig, and not the 127.0.0.1!
Never assume that a web server has only one IP address. It isn't
that uncommon for a web server to occupy an entire class C. (253
usable addresses or so.)
So the slow way I have figured out is to do a system call to doc, using `ipconfig`, and then regex the result and figure out the ip. Is there a fater/more efficient way to do this?
If you want the IP address that the client contacted the server on,
look at $_SERVER['SERVER_ADDR']. This may well vary if the server
has IP-based virtual hosts, and it might end up being 127.0.0.1 if
you accessed it with http://127.0.0.1/foo.php from your browser on
the server itself.
Gordon L. Burditt
"steve" <Us************ @dbForumz.com> wrote in message
news:Tv******** **********@cycl ops.nntpserver. com... Hi, I am running apache on local pc/ under Windows.
I need to figure out the ip number of the pc inside PHP. This is the number available when you do ipconfig, and not the 127.0.0.1!
So the slow way I have figured out is to do a system call to doc, using `ipconfig`, and then regex the result and figure out the ip. Is there a fater/more efficient way to do this?
-- http://www.dbForumz.com/ This article was posted by author's request Articles individually checked for conformance to usenet standards Topic URL:
http://www.dbForumz.com/PHP-Find-loc...ict131475.html Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=438714
gethostbynamel( $dns_name_of_co mputer).
"Chung Leong" wrote: "steve" <Us************ @dbForumz.com> wrote in message news:Tv******** ********@cyclop s.nntpserver.co m... Hi, I am running apache on local pc/ under Windows.
I need to figure out the ip number of the pc inside PHP. This is the number available when you do ipconfig, and not the 127.0.0.1!
So the slow way I have figured out is to do a system call to doc, using `ipconfig`, and then regex the result and figure out the ip. Is there a fater/more efficient way to do this?
-- http://www.dbForumz.com/ This article was posted by author’s request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbForumz.com/PHP-Find-loc...ict131475.html Visit Topic URL to contact author (reg. req’d). Report abuse: http://www.dbForumz.com/eform.php?p=438714
gethostbynamel( $dns_name_of_co mputer).
I don’t have DNS on my pc, so I tried
gethostbynamel( ’localhost’)
but it returns 127.0.0.1
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Find-loc...ict131475.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=438855
"steve" wrote: [quote:a57631114 3="steve"][quote:a57631114 3="Chung
Leong"]"steve" <Us************ @dbForumz.com> wrote in message news:Tv******** ********@cyclop s.nntpserver.co m... Hi, I am running apache on local pc/ under Windows.
I need to figure out the ip number of the pc inside PHP. This is the number available when you do ipconfig, and not the 127.0.0.1!
So the slow way I have figured out is to do a system call to doc, using `ipconfig`, and then regex the result and figure out the ip. Is there a fater/more efficient way to do this?
-- http://www.dbForumz.com/ This article was posted by author’s request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbForumz.com/PHP-Find-loc...ict131475.html Visit Topic URL to contact author (reg. req’d). Report abuse: http://www.dbForumz.com/eform.php?p=438714
gethostbynamel( $dns_name_of_co mputer).
I don’t have DNS on my pc, so I tried
gethostbynamel( ’localhost’)
but it returns 127.0.0.1[/quote:a57631114 3]
It works! must do it this way:
$hosts=gethostb ynamel(’’); (see http://ca2.php.net/manual/en/functio...stbynamel.php)[/quote:a57631114 3]
And a quick note, the $hosts variable above is an array. Take
$hosts[0] as the IP number!
"steve" <Us************ @dbForumz.com> wrote in message
news:wk******** *********@cyclo ps.nntpserver.c om... > gethostbynamel( $dns_name_of_co mputer). I don't have DNS on my pc, so I tried gethostbynamel( 'localhost') but it returns 127.0.0.1[/quote:a57631114 3]
It works! must do it this way: $hosts=gethostb ynamel(''); (see http://ca2.php.net/manual/en/functio...stbynamel.php)[/quote:a57631114 3] And a quick note, the $hosts variable above is an array. Take $hosts[0] as the IP number!
Just to clarify: getbyhostname(' localhost') *should* return 127.0.0.1, since
it almost always
defined as such in your hosts file. You should actually either use '', like
you did, or your known
machine name 'someserver.som edomain.com' if you want its actual IP.
And you don't need to have DNS on your PC, if you can look up *any* hostname
(not already
defined in your hosts file) then you are accessing a DNS server somewhere.
(look up anything
via nslookup at a command line, and it will tell you what server you are
currently using as part of
its response.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Olly |
last post by:
Find an id number not present in a linking table
I have a linking table (tblPayment) that monitors the subscriptions
from members. However, I need a query that can compare the ID number
fields from both tables, and show the ID numbers only that are not in
tblPayment.
My current query is like the one bellow:
MemberID MemberID Year Term
|
by: Klaus Drechsel |
last post by:
My Problem:
The Function Dispose on a IDisposable shuld be called on the last reference
to this instance. Can I get the number of references. to an object?
Klaus Drechsel
|
by: Mahesh BS |
last post by:
Hello,
I need to write a query to find out a set of missing number in a given
sequence.
Eg : a Column in some table has the following data
|
by: svlsr2000 |
last post by:
Can any one give me best algorithm to find nth ugly number.
|
by: Simon |
last post by:
Dear reader,
Is there a function or VBA code available to find the week number out of a
date field.
You can find the year with Year(date field) but now I need the week number
out of a date field.
| |
by: rajukotla |
last post by:
How to find out the number of days in a financial year.
suppose from date is sep1st,2006.and to date is aug24th,2009.
the entire range involves financial years.i.e.,
april1st,2006-march31st,2007
april1st,2007-march31st,2008
april1st,2008-march31st,2009
april1st,2009-march31st,2010.
|
by: Revathi Balakrishnan |
last post by:
Hi All
Is it possible to find out the number of frames the page contain?
For example my page is divided in to three frames using frameset tag, and one of my frame has i frame also. Like such cases, Is there any easy way to find ou the number of frames with out looking in to the code?
Any of your advice would be much appreciated
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |