PHP gethostbyname() doesn't work in Linux with xampp
Posted: 15. June 2014 19:27
0 down vote favorite
Hi I want to obtain my ip number in php, I'm using ubuntu and apache XAMPP for linux as webserver.
When I execute the code it returns 127.0.0.1 What I want is like i.e 10.151.32.123. This code works in windows with xampp, why this code doesn't work in Linux?
Hi I want to obtain my ip number in php, I'm using ubuntu and apache XAMPP for linux as webserver.
- Code: Select all
<?php
echo $gethostname = gethostbyname(gethostname());
?>
When I execute the code it returns 127.0.0.1 What I want is like i.e 10.151.32.123. This code works in windows with xampp, why this code doesn't work in Linux?