Website Scripts And Cloud Tutorials

Get public IP address of system using php

Byadmin

Oct 25, 2011

Last updated on May 26th, 2016 at 01:40 pm

Click to rate this tutorial!
[Total: 0 Average: 0]

Get public IP address of system using php

Get the ip address of the system [usually assigned by ISP], the public ip address using PHP. This code should run on a Windows server.

ob_start();
system('ipconfig /all'); 
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); 
$findme = "IP Address";
$pos = strpos($mycom, $findme);
$ip=substr($mycom,($pos+36),17);
echo "The IP address of this system is :".$ip;

Check Get MAC Address Using PHP (Linux & Windows)
Here we are using Output buffer. CLICK HERE to take a look at what is Output buffering in php.

Click to rate this tutorial!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published.