# Environment Variables PHP

PHP also makes environment variables available. These are the variables that are created when you start a new shell. Some are the standard variables like PATH. Others are variables defined by the CGI. Examples are REMOTE_ADDR and HTTP_USER_AGENT. These are turned into PHP variables for your convenience. tells you which browser someone is using to surf your page.

Similar to environment variables are the variables the PHP itself creates for you. The first is GLOBALS, which is an associative array of every variable available to the script. Exploring this array will reveal all the environment variables as well as a few other ariables. Similar to GLOBALS are HTTP_GET_VARS, HTTP_POST_VARS, and HTTP_COOKIE_VARS. As their names suggest, these are associative arrays of the variables created by the three methods the browser may use to send information to the server.

The combination of Web server and operating system will define the set of environment variables. You can always write a script to dump the GLOBALS array to see which are available to you. Alternatively, you can simply view the output of the phpinfo function.

Viewing Environment Variables

<?
/*
** make a multiplication table
*/
// start table
print("<TABLE BORDER="1"> ");
for($Row=1;$Row=12; $Row++) { //start row print("<TR> "); //do each column for($Column=1; $Column <= 12;$Column++)
{
print("<TD>");
print($Row *$Column);
print("</TD>");
}
//end row
print("</TR> ");
}
//end table
print("</TABLE> ");
?>