How to identify server IP address in PHP
How to identify server IP address in PHP
or the server ip:
$_SERVER['SERVER_ADDR'];
and this for the port
$_SERVER['SERVER_PORT'];
You can use this in CRUL as below:
<?php
// create a new cURL resource
$ch = curl_init ();
// set URL and other appropriate options
curl_setopt ($ch, CURLOPT_URL, "http://blog.eduguru.in/test");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$ip = curl_exec ($ch);
echo "The public ip for this server is: $ip";
// close cURL resource, and free up system resources
curl_close ($ch);
?>