PHP Learning Notes [predefined array (Hyper Global array)]_php base

Source: Internet
Author: User
Tags arrays http post

Copy Code code as follows:

<?php
/* Predefined arrays:
* AUTO global variable---Super global array
*
* 1. Contains data from Web server, client, running 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 the array operations they define
* 5. These arrays can be used directly in functions
*
* $_get//variable submitted to script via URL request
* $_post//variable submitted to script via HTTP POST method
* $_request//variable submitted to script via get, post and cookie mechanism
* $_files//variable submitted to script via HTTP POST method file upload
* $_cookie
* $_session
* $_env//Execution Environment submitted to script variables
* $_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 valid variables are here, the array's key name is the name of the global script
*
*
*/
A super global array can be called directly inside a function
$arr =array (10,20);//General array
$_get=array (50,90);//Super Global array
Function Demo () {
The global $arr;//Calling globally variable to include first
Print_r ($arr);
Print_r ($_get);//Direct call to a super global array without including
}
?>
<!--********** Page pass value GET request ***************-->
<?php
Direct transfer of the value variable used, when the php.ini configuration file Register_global=on useful.
echo $username. " <br> ";
echo $email. " <br> ";
echo $page. " <br> ";
The most stable value-taking method
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 Transfer 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);/Not Received
Print_r ($_post);//So that you can receive
?>
<?php
The use of $_env
Echo ' <pre> ';
Print_r ($_ENV);
Echo ' </pre> ';
Show Current environment
You can also traverse a single
?>
<?php
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"]. " <br> ";
echo $GLOABLS ["B"]. " <br> ";
echo $GLOABLS ["C"]. " <br> ";
}
?>

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.