PHP has a collection of environment variables, which are system defined variables that are accessible from anywhere inside the PHP code. All of these environment variables are stored by PHP as arrays. Some you can address directly by using the name of the index position as a variable name. Other can only be accessed through their arrays.
Some of the environment variables include:
$_SERVER – Contains information about the server and the HTTP connection. Analogous to the old $HTTP_SERVER_VARS array (which is still available, but deprecated).
$_COOKIE – Contains any cookie data sent back to the server from the client. Indexed by cookie name. Analogous to the old $HTTP_COOKIE_VARS array (which is still available, but deprecated).
$_GET – Contains any information sent to the server as a search string as part of the URL. Analogous to the old $HTTP_GET_VARS array (which is still available, but deprecated).
$_POST – Contains any information sent to the server as a POST style posting from a client form. Analogous to the old $HTTP_POST_VARS array (which is still available, but deprecated).
$_FILE – Contains information about any uploaded files. Analogous to the old $HTTP_POST_FILES array (which is still available, but deprecated).
$_ENV – Contains information about environmental variables on the server. Analogous to the old $HTTP_ENV_VARS array (which is still available, but deprecated).
The code to use the environment variables will be as follows:
<?php
// moderate shortcut
$newVar = $_COOKIE["myFirstCookie"];
// full version
$newVar = $HTTP_COOKIE_VARS["myFirstCookie"];
?>
Filed under: PHP, Web Application, Web Devlopment | Tagged: google | Leave a Comment »
