Re: Get Local IP Address
| From: | Tom Rogers | Date: | Mon, 28 Jul 2003 02:37:40 +0000 |
| Subject: | Re: Get Local IP Address | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157128@lists.php.net to get a copy of this message | ||
Hi,
Monday, July 28, 2003, 12:21:06 PM, you wrote:
CL> How can I get the local Computer IP Address when running PHP program in
CL> Windows command line (i.e. php getmyip.php)
CL> ** Since the PHP did not are run on Webserver, so _SERVER["SERVER_ADDR"]
CL> won't work.
CL> Many thanks in advance.
CL> Regards,
CL> Chris
Try this:
<?php
exec('ipconfig',$catch);
foreach($catch as $line){
if(eregi('IP Address',$line)){
list($t,$ip) = split(':',$line);
echo 'IP is '.$ip."\n";
}
}
?>
--
regards,
Tom