Superglobal variables, introduced in PHP 4.1.0, are built-in variables that are always available in all scopes. Many predefined variables in PHP are "superglobal," meaning they are available throughout the entire scope of a script. They can be accessed within a function or method without executing global $variable;.
There are 9 commonly used super global variables:
1. $_GET –> get transmission method
2. $_POST –> post transmission method
3. $_REQUEST –> can receive values in both get and post methods
4. $GLOBALS –> references all variables available in the global scope
5. $_FILES –> Use to upload files
6. $_SERVER –> System environment variables
7. $_SESSION –> Used for session control
8. $_COOKIE –> Used for session control
9. $_ENV –> Server-side environment variable
The following will give you a detailed introduction
1. $_GET –> get transmission method
PHP $_GET can also be used to collect the data after submitting the HTML form (method="get") Form data.
$_GET can also collect data sent in the URL.
For example, access the URL link:
http://localhost/test_get.php?subject=PHP&web=W3school.com.cn
The usage method is as follows:
<html> <body> <?php echo "Study " . $_GET['subject'] . " at " . $_GET['web']; ?> </body> </html>
2. $_POST –> post transmission method
PHP $_POST is widely used to collect form data after submitting an HTML form with method="post". $_POST is also commonly used to pass variables.
The following example shows a form containing input fields and a submit button. When the user clicks the submit button to submit the data, the form data is sent to the file specified in the action attribute of the