PHP Basic Data Type Step By Step Tutorial - Part 14:Variable from the outside PHP is also often referred to as web server variable. Variable of server web will contain the data that is related to the server web and operating server web system.
PHP_SELF variable is used for many times to automate a link which relate each other. Beneath, there are a number of variables of server web which often required and used:
- DOCUMENT_ROOTcontain of name document directory of web
- PHP_SELF contain of information name of accessed script.
- HTTP_USER_AGENT contain of information used browser.
- REMOTE_ADDR contain of address information of IP visitor.
- SERVER_NAME contain of name of server.
- SERVER_SOFTWARE contain of name used by software server web.
- SERVER_PORT containing of port number information used for connection to web server.
- SERVER_PROTOCOL which express the name of protocol.
- REQUEST_METHOD containing of information of method request - GET or POST.
Pay attention to the example of using PHP variable as following:
File name: phpself.php
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?
print ("Your directory script : ".
$DOCUMENT_ROOT."<br>");
print ("Your script : ".$PHP_SELF."<br>");
print ("Your browser : ".$HTTP_SERVER_VARS['HTTP_USER_AGENT']."<br>");
print ("Your IP : ".$HTTP_SERVER_VARS['REMOTE_ADDR']."<br>");
print ("Your server name : ".$HTTP_SERVER_VARS['SERVER_NAME']."<br>");
print ("Your server web name : ".$HTTP_SERVER_VARS['SERVER_SOFTWARE']."<br>");
print ("Your port server : ".$HTTP_SERVER_VARS['SERVER_PORT']."<br>");
print ("Your protocol : ".$HTTP_SERVER_VARS['SERVER_PROTOCOL']."<br>");
?>
</body>
</html>