Home  >  Article  >  Backend Development  >  PHP study notes [Predefined array (super global array)]_PHP tutorial

PHP study notes [Predefined array (super global array)]_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:28:33840browse

Copy code The code is as follows:

/* Predefined array:
* Automatic Global variables --- super global array
*
* 1. Contains data from WEB server, client, running environment and user input
* 2. These arrays are special
* 3. It takes effect automatically in the global scope, and you can use these arrays directly
* 4. Users cannot customize these arrays, but the operation methods of these arrays are the same as those defined by themselves
* 5. Directly in the function You can use these arrays
*
* $_GET //Variables submitted to the script via URL request
* $_POST //Variables submitted to the script via the HTTP POST method
* $_REQUEST //Via Variables submitted to the script by GET, POST and COOKIE mechanisms
* $_FILES //Variables submitted to the script via http post method file upload
* $_COOKIE
* $_SESSION
* $_ENV / /Variables submitted by the execution environment to the script
* $_SERVER //Variables are set by the WEB server, or directly associated with the execution environment of the current script
* $GLOBALS //As long as the variables are valid for the current script Here, the key name of the array is the name of the global script
*
*
*/
//The super global array can be called directly inside the function
$arr=array(10,20 );//General array
$_GET=array(50,90);//Super global array
function demo(){
global $arr;//When calling global variables, you must first include
print_r($arr);
print_r($_GET); // Directly call the super global array without including
}
?>

//Use the passed value directly as a variable, as php. Useful when register_global=on in ini configuration file.
echo $username."
";
echo $email."
";
echo $page."
";
//The most stable Value method
echo $_GET["username"]."
";
echo $_GET["email"]."
";
echo $_GET["page "]."
";
?>
this is a $_GET test< /a>


username:

password:< ;input type="password" name="pass" />



< ;/form>
print_r($_GET);//Cannot receive
print_r($_POST);//This is how to receive
?>
< ;?php
//Usage of $_ENV
echo'
'; <br>print_r($_ENV); <br>echo'
';
//Display Current environment
// You can also traverse individually
?>
//Use the $GLOBALS super-global array to call global variables inside the function
$a=100;
$b=200;
$c=300;
function demo()
{
//Directly call global variables
echo $GLOBALS["a"]."< br>";
echo $GLOABLS["b"]."
";
echo $GLOABLS["c"]."
";
}
? >

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323578.htmlTechArticleCopy the code as follows: ?php /* Predefined array: * Automatic global variable---super global array* * 1. Contains data from WEB server, client, operating environment and user input*...