PHP Learning notes [pre-defined array (Hyper-global Array)]_php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
/* pre-defined array:
* AUTO global variable---Hyper global array
*
* 1. Contains data from the Web server, client, run environment and user input
* 2. These arrays are more specific
* 3. The global scope automatically takes effect, you can use these arrays directly
* 4. Users cannot customize these arrays, but these arrays operate in the same way as array operations of their own definition
* 5. These arrays can be used directly in the function
*
* $_get//The variable submitted to the script via URL request
* $_post//variables submitted to the script via the HTTP POST method
* $_request//variables submitted to the script via get, post and cookie mechanism
* $_files//variables submitted to the script via HTTP POST method file upload
* $_cookie
* $_session
* $_env//Execution Environment commit to script variable
* $_server//variables are set by the Web server or are directly associated with the execution environment of the current script
* $GLOBALS//As long as the current script is valid variables are here, the array's key name is the name of the global script
*
*
*/
A hyper-global array can be called directly inside a function
$arr =array (10,20);//General array
$_get=array (50,90);///Hyper Global Array
Function Demo () {
Global $arr;//The call is to first include
Print_r ($arr);
Print_r ($_get);//directly calling a hyper-global array does not include
}
?>

Use the worth variable directly, which is useful when register_global=on in the php.ini configuration file.
echo $username. "
";
echo $email. "
";
echo $page. "
";
The most stable method of taking value
echo $_get["username"]. "
";
echo $_get["email"]. "
";
echo $_get["page"]. "
";
?>
This is a $_get test


Print_r ($_get);//cannot receive
Print_r ($_post);//To receive
?>
Use of $_env
Echo


Echo
';
Show Current environment
You can also traverse a single
?>
Calling global variables inside a function using a $globals hyper-global Array
$a = 100;
$b = 200;
$c = 300;
Function Demo ()
{
Calling global variables directly
echo $GLOBALS ["a"]. "
";
echo $GLOABLS ["B"]. "
";
echo $GLOABLS ["C"]. "
";
}
?>

http://www.bkjia.com/PHPjc/323578.html www.bkjia.com true http://www.bkjia.com/PHPjc/323578.html techarticle Copy the code as follows:? PHP/* Predefined array: * Auto global variable---Hyper global array * * 1. Contains data from Web server, client, run environment and user input * ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.