You can obtain the local IP address of a system using PHP by using the following code:
$local_ip = getHostByName(getHostName());
echo $local_ip;
This code uses the getHostName()
function to get the hostname of the local system, and then uses the getHostByName()
function to get the IP address associated with that hostname. The IP address is then stored in the $local_ip
variable and printed out.
Asked: 2021-11-08 11:00:00 +0000
Seen: 9 times
Last updated: Nov 10 '22