How to identify server IP address in PHP
for example:
$_SERVER['SERVER_ADDR']
when your on IIS, try:
$_SERVER['LOCAL_ADDR']
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.
Like this for the server ip:
$_SERVER['SERVER_ADDR'];
and this for the port
$_SERVER['SERVER_PORT'];