Alex Rivera | Logout

How to identify server IP address in PHP

Asked 2011-04-27T07:45:56.577
146

How can I identify the server IP address in PHP?

Edit
Report

1 Answer

128

If you are using PHP version 5.3 or higher you can do the following:

$host= gethostname();
$ip = gethostbyname($host);

This works well when you are running a stand-alone script, not running through the web server.

answered 2013-06-11T20:50:52.640

Your Answer