How to figure out your server’s real name

It is sometimes necessary to figure out the real server name. There are several ways to do this, but in PHP, a simple way is this:

$SERVER_NAME = $_SERVER["SERVER_NAME"];
$IP = gethostbyname ($SERVER_NAME);
$server = gethostbyaddr($IP);
echo "<br>Server IP: $IP";
echo "<br>Server Name: $server";

If you do not want to see the IP address of your website, you can use this single line of code:

echo "Server Name: " . gethostbyaddr (gethostbyname ($_SERVER["SERVER_NAME"]));

A demo can be found here.

Leave a Reply

 

Site Navigation

Popular Pages

The most popular pages on eKstreme.com.

Search

Subscribe

Subscribe to RSS 2.0 feed

Community

 
thermodelly