Ask Your Question
1

How can you obtain the local IP address of a system using PHP?

asked 2021-11-08 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-11-10 12:00:00 +0000

woof gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-11-08 11:00:00 +0000

Seen: 9 times

Last updated: Nov 10 '22