php study notes [predefined array of super global array]

  • 2020-05-07 19:21:53
  • OfStack


<?php 
/*  Predefined array:  
*  Automatic global variable --- Superglobal array  
* 
* 1. Contains information from WEB Server, client, runtime environment, and user input data  
* 2. These arrays are special  
* 3. These arrays can be used directly in the global scope  
* 4. The user cannot customize these arrays, but the way they are manipulated and the way they are manipulated 1 sample  
* 5. You can use these arrays directly in a function  
* 
* $_GET // through URL Requests variables to be submitted to the script  
* $_POST // through HTTP POST  Method is submitted to the script's variables  
* $_REQUEST // through GET , POST and COOKIE Mechanism to submit   To script variables  
* $_FILES // through http post A variable that is submitted to a script when the method file is uploaded  
* $_COOKIE 
* $_SESSION 
* $_ENV // Variables that the execution environment commits to the script  
* $_SERVER // Variables by WEB Of, or directly associated with, the execution environment of the current script  
* $GLOBALS // Any variables that are valid for the current script are here, and the array key is the name of the global script  
* 
* 
*/ 
// The superglobal array can be called directly from within the function  
$arr=array(10,20);//1 As an array  
$_GET=array(50,90);// Superglobal array  
function demo(){ 
global $arr;// Global variables are called with inclusion first  
print_r($arr); 
print_r($_GET);// Direct calls to a superglobal array do not include  
} 
?> 
<!-- ********** Page by value get request *************** --> 
<?php 
// Use the value directly as a variable , when php.ini In the configuration file register_global=on When useful.  
echo $username."<br>"; 
echo $email."<br>"; 
echo $page."<br>"; 
// The most stable way to evaluate it  
echo $_GET["username"]."<br>"; 
echo $_GET["email"]."<br>"; 
echo $_GET["page"]."<br>"; 
?> 
<a href="demo.php?username=zhangsan&email=aaa@bbb.com&page=45">this is a $_GET test</a> 
<!-- *********** Page by value post request **************** --> 
<form action="demo.php" method="post"> 
username:<input type="text" name="uname" /> <br/> 
password:<input type="password" name="pass" /> <br/> 
<input type="submit" value="login" /> <br /> 
</form> 
<?php 
print_r($_GET);// Can't receive  
print_r($_POST);// That's how you get it  
?> 
<?php 
//$_ENV The use of  
echo'<pre>'; 
print_r($_ENV); 
echo'</pre>'; 
// Display the current environment  
//  It can also be traversed individually  
?> 
<?php 
// using $GLOBALS The super global array calls the global variable inside the function  
$a=100; 
$b=200; 
$c=300; 
function demo() 
{ 
// Call global variables directly  
echo $GLOBALS["a"]."<br>"; 
echo $GLOABLS["b"]."<br>"; 
echo $GLOABLS["c"]."<br>"; 
} 
?> 


Related articles: