tedddy7
tedddy7

Reputation: 1

How do I display the local ip of my computer on a php page?

I have a PHP page that displays information like Server IP, The External IP of my ISP provider. I want to also display the IP address assigned to my Compute from my DHCP Router.

It should automatically know whether it is eth0 or WLAN0 and use it.

NOTE: Everything I have come across seems to display 127.0.1.1 I DON'T want that.

I prefer a 1 liner if possible!

I've tried:

$localIP = getHostByName(php_uname('n'));
$localIP = getHostByName(gethostname());
$localIP = gethostbyname(trim(exec("hostname --all-ip-address")));

The last one returns the Servers IP & the WLAN0. But the WLAN0 is for the Server as well, NOT my Computer.

Upvotes: 0

Views: 60

Answers (0)

Related Questions