By: Emiley J. Printer Friendly Format
As a general rule, PHP does not support global variables (variables that can automatically be accessed from any scope). However, certain special internal variables behave like global variables similar to other languages. These variables are called superglobals and are predefined by PHP for you to use. Some examples of these superglobals are
. $_GET. An array that includes all the GET variables that PHP received from the client browser.
. $_POST. An array that includes all the POST variables that PHP received from the client browser.
. $_COOKIE. An array that includes all the cookies that PHP received from the client browser.
. $_ENV. An array with the environment variables.
. $_SERVER. An array with the values of the web-server variables.
On a language level, it is important to know that you can access these variables anywhere in your script whether function, method, or global scope. You don’t have to use the $GLOBALS array, which allows for accessing global variables without having to predeclare them or using the deprecated globals keyword.
Most Viewed Articles (in PHP )
Latest Articles (in PHP)
Comment on this tutorial
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews