There are 9 php super global variables, namely: "$GLOBALS", "$_SERVER", "$_GET", "$_POST", "$_FILES", "$_COOKIE", "$_SESSION" ”, “$_REQUEST”, “$_ENV”.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Many predefined variables in PHP are " "superglobal", which means they are available throughout the entire scope of a script. They can be accessed within a function or method without executing global $variable;
.
These superglobal variables are:
$GLOBALS
$_SERVER
$_GET
$_POST
$_FILES
$_COOKIE
$_SESSION
$_REQUEST
$_ENV
PHP $_GET can also be used to collect form data after submitting an HTML form (method="get").
$_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 is as follows:
<html> <body> <?php echo "Study " . $_GET['subject'] . " at " . $_GET['web']; ?> </body> </html>
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