Get Server Information with PHP

From this example you will learn about the variables to get server information that are pre-defined to PHP libraries. Here I have just print the result. You can put the result in any variable and modify as your need. Here I have just draw a table in PHP file on which the server information will embossed.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Get Server Information | tutpub.com</title>
</head>
<body>
<table style=”border:1px solid #CCCCCC; background-color:#F0F0F0; font-family:verdana; font-size:12px; margin:0 auto;” cellpadding=”5″ cellspacing=”2″ width=”600px”>
<tr>
<td colspan=”4″ align =”center”><h3>Server Information</h3></td>
</tr>
<tr>
<td>Server Name: <?php echo $_SERVER[‘SERVER_NAME’]; ?></td>
</tr>
<tr>
<td>Server Address: <?php echo $_SERVER[‘SERVER_ADDR’]; ?></td>
</tr>
<tr>
<td>Server Protocol: <?php echo $_SERVER[‘SERVER_PROTOCOL’]; ?></td>
</tr>
<tr>
<td>Server Method: <?php echo $_SERVER[‘REQUEST_METHOD’]; ?></td>
</tr>
<tr>
<td>Server Software: <?php echo $_SERVER[‘SERVER_SOFTWARE’]; ?></td>
</tr>
<tr>
<td>Server Request Time: <?php echo $_SERVER[‘REQUEST_TIME’]; ?></td>
</tr>
<tr>
<td>Server Gaetway Interface: <?php echo $_SERVER[‘GATEWAY_INTERFACE’]; ?></td>
</tr>
<tr>
<td>Document Root: <?php echo $_SERVER[‘DOCUMENT_ROOT’]; ?></td>
</tr>
<tr>
<td>HTTP_Accept Language: <?php echo $_SERVER[‘HTTP_ACCEPT_LANGUAGE’]; ?></td>
</tr>
<tr>
<td>HTTP Connection: <?php echo $_SERVER[‘HTTP_CONNECTION’]; ?></td>
</tr>
<tr>
<td>HTTP Host: <?php echo $_SERVER[‘HTTP_HOST’]; ?></td></tr>
<tr>
<td>HTTP User Agent: <?php echo $_SERVER[‘HTTP_USER_AGENT’]; ?></td>
</tr>

<tr>
<td>Remote Address: <?php echo $_SERVER[‘REMOTE_ADDR’]; ?></td>
</tr>
<tr>
<td>Remote Host: <?php echo $_SERVER[‘HTTP_HOST’]; ?></td>
</tr>
<tr>
<td>Remote Port: <?php echo $_SERVER[‘REMOTE_PORT’]; ?></td>
</tr>
<tr>
<td>Server_Admin: <?php echo $_SERVER[‘SERVER_ADMIN’]; ?></td>
</tr>
<tr>
<td>Server Port: <?php echo $_SERVER[‘SERVER_PORT’]; ?></td>
</tr>
</table>
</body>
</html>

Result will be like as the snap shot:

Server Informations Snapshot

 

Author Info

Shah Alom

Hi, This is Mohammad Shah Alom, My passion is Programming & Web Development. I am Founder of Micro Solutions Bangladesh. My Facebook profile shahalom1983 & Twitter Profile shahalom_83