Printing server information


 

Printing server information

This example will inform you about how to print server information in PHP.

This example will inform you about how to print server information in PHP.

Printing server information

This example will teach you how to print the server information on the screen connected to your PC. For printing the server information, first you will have to create a HTML form and post the action form into PHP code. The PHP code will call the action form to print the server information on the form. 

First create a HTML form named form for posting it on PHP code.

Set the action to print server information from which your computer is connected.

Draw a table in HTML on which the server information will embossed. 

Begin the php code, define the variables of server.

Set the HTTP server and remote it. 

Call  the action form and print the table. 

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>ServerInformation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body > 
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<table style="border:1px solid #CCCCCC; background-color:#F0F0F0; font-family:verdana; font-size:12px" cellpadding="5" cellspacing="2" width="600px"> 
<tr>
<td><li><a href="serverinfo.php" target="content">Server Information</a></li></td> 
</tr>
</table>
</form>
</body>
</html>

<?php
$servername= $_SERVER['SERVER_NAME'];
$serveraddress= $_SERVER['SERVER_ADDR'];
$serverprotocol= $_SERVER['SERVER_PROTOCOL'];
$servermethod= $_SERVER['REQUEST_METHOD'];
$serversoftware= $_SERVER['SERVER_SOFTWARE'];
$servergateinterface= $_SERVER['GATEWAY_INTERFACE'];
$serverreqtime= $_SERVER['REQUEST_TIME'];
$documentroot= $_SERVER['DOCUMENT_ROOT'];

$HTTP_ACCEPT_LANGUAGE= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$HTTP_CONNECTION= $_SERVER['HTTP_CONNECTION'];
$HTTP_HOST= $_SERVER['HTTP_HOST'];
$HTTP_USER_AGENT= $_SERVER['HTTP_USER_AGENT'];
$REMOTE_ADDR= $_SERVER['REMOTE_ADDR'];
$REMOTE_HOST= $_SERVER['REMOTE_HOST'];
$REMOTE_PORT= $_SERVER['REMOTE_PORT'];
$SERVER_ADMIN= $_SERVER['SERVER_ADMIN'];
$SERVER_PORT= $_SERVER['SERVER_PORT'];
?>
<table style="border:1px solid #CCCCCC; background-color:#F0F0F0; font-family:verdana; font-size:12px" cellpadding="5" cellspacing="2" width="600px"> 
<tr>
<td colspan="4" align ="center"><h3>Server Information</h3></td>
</tr>
<tr><td>Server Name:<?= $servername; ?></td></tr>
<tr><td>Server Address:<?= $serveraddress; ?></td></tr>
<tr><td>Server Protocol:<?= $serverprotocol; ?></td></tr>
<tr><td>Server Method:<?= $servermethod; ?></td></tr>
<tr><td>Server Software:<?= $serversoftware; ?></td></tr>
<tr><td>Server Request Time:<?= $serverreqtime; ?></td></tr>
<tr><td>Server Gaetway Interface:<?= $servergateinterface; ?></td></tr>
<tr><td>Document Root:<?= $documentroot; ?></td></tr>

<tr><td>HTTP_Accept Language:<?= $HTTP_ACCEPT_LANGUAGE; ?></td></tr>
<tr><td>HTTP Connection:<?= $HTTP_CONNECTION; ?></td></tr>
<tr><td>HTTP Host:<?= $HTTP_HOST; ?></td></tr>
<tr><td>HTTP User Agent:<?= $HTTP_USER_AGENT; ?></td></tr>

<tr><td>Remote Address:<?= $REMOTE_ADDR; ?></td></tr>
<tr><td>Remote Host:<?= $REMOTE_HOST; ?></td></tr>
<tr><td>Remote Port:<?= $REMOTE_PORT; ?></td></tr>
<tr><td>Server_Admin:<?= $SERVER_ADMIN; ?></td></tr>
<tr><td>Server Port:<?= $SERVER_PORT; ?></td></tr>

</table>

In the output, you will see the complete server information which has been asked in the program.

Ads