PHP Superglobals
Superglobals are variable that are automatically available throughout all program code,in all scopes.
These variables require no declaration they can simply be accessed. Super global variables provide:
$SERVER has also been around since PHP 4.1.0 Before that, $HTTP_SERVER_VARS was used through this was not automatically global
These variables require no declaration they can simply be accessed. Super global variables provide:
- Useful information about the environment
- Allow access to HTML form variables or parimeters
- Access to cookies stored on a client
- Keeping track of sessions and file uploads
- $_GET - $_GET is used for data passed using the HTTP GET method,which includes variables passed as part of the URL. For Example: www.designevlop.blogspot.com/index.php?book=PHP&cat=linux The GET method is conventionally used when the processing script has no lasting observable effect,such as changing a value in a database table. $_GET has been around since PHP 4.1.0 Before that,$HTTP_GET_VARS was used though this was not automatically global.
- $_POST- The HTTP POST method is very similar to the $_GET .It is conventionally used when the contents of an HTML form are going to change values in a database table or make some other permanent change $_POST has been around since PHP 4.1.0 Before that,$HTTP_POST_VARS was used though this was not automatically global.
- $_REQUEST - $_REQUEST holds variables provided to the script via the GET,POST and COOKIE input mechanism. The presence and the order of variable inclusion in this array are defined according to the PHP variables_order configuration directive. It is preferable to use this specific super global variable, if it is not known how the variables are being passed (i.e. which method GET or POST is being used ) for a particular script Additionally, this super global variable also contains all the information contained in $_COOKIE. $_REQUEST can be put into action simply by replacing $_POST or $_GET with $_REQUEST and the result would be identical $_REQUEST has also been around since PHP 4.1.0 before version 4.3.0, in addition to the contents of $_POST,$_GET and $_COOKIE,$_REQUEST also contained $_FILES information
- $_GLOBALS - This is a final super global variable that can be used for forms. This would mean it is a super super global, as it contains reference to all variables in the script's global scope. Replacing $_POST or $_GET with $_GLOBALS in the examples above would also have the identical results. The keys of this array are names of the global variables $_GLOBALS has been around since php 3.0.0
- $_COOKIE - $_COOKIE contains all variable passed from HTTP cookies $_COOKIE has been around since PHP 4.1.0 Before that,$HTTP_COOKIE_VARS was used though this was not automatically global
- $_FILES - $_FILES holds variable provided to the script via HTTP post file uploads to provide feedback to the script $_FILES has also been around since PHP 4.1.0 Before that ,$HTTP_POST_FILES was used though this was not automatically global
- $_ENV - $_ENV holds variables provided to the script via the environment. Analogues to the old $HTTP_ENV_VATS array ,which is still available ,but deprecated
- $SESSION - $SESSION holds variables which are currently registered to a script session
- $SERVER - Variables set by the web server or otherwise directly related to the execution environment of the current script
Comments
Post a Comment