PHP - PHP Superglobals

PHP Superglobals.

These are predefined variables that are by default available globally. They represent data coming from URLs, HTML forms, cookies, sessions, and the Web server itself.

1. $_COOKIE – Represents data available to the PHP script via HTTP cookies.
2. $_GET – Represents data sent to the PHP script using HTTP get method.
3. $_POST – Represents data sent to the PHP script using HTTP post method.
4. $_REQUEST – It is a combined array containing values from the $_GET, $_POST, and $_COOKIES superglobal arrays.
5. $_ENV – Represents data available to the PHP script from the environment in which PHP is running.
6. $_FILES – Represents data sent to the PHP script from HTTP POST of uploaded files.
7. $_SERVER – It contains variables made available by the web server server.
8. $GLOBALS – It contains all the global variables associated with the current script.

PHP Superglobals.

To access the global data which is originating externally, the super globals are used. The superglobals are available as arrays. These superglobals represents the data from URLs, HTML forms, cookies, sessions and also the web server. For this purpose, $HTTP_GET_VARS, $HTTP_POST_VARS are used. The super globals are pretty good enough to be used in functions. The following are the list of super globals.

$_GET, $_POST, $_COOKIE;$_REQUEST, $_SERVER, $_SESSION, $_ENV, $_FILE

Another PHP Superglobal, called $GLOBALS; is available for persisting every variable with global scope.
PHP - What is the difference between mysql_connect() and mysql_pconnect()?
What is the difference between mysql_connect() and mysql_pconnect()? - When mysql_pconnect() is used, the function initially tries to find an open persistent connection....
PHP - Explain with code how to get a user's IP address.
Explain with code how to get a user's IP address - The users IP address can be returned by specifying the host name as aparameter in gethostbyname(“hostname”) method....
PHP - Explain with code how to generate a random number from php.
Explain with code how to generate a random number from php - The function rand() can be used to generate random number....
Post your comment