Ec (2); & nbsp; $ globals array & nbsp; functiontestfunction () {& nbsp; echo $ globals [& quot; php_self & quot;]; & nbsp ;}& nbsp; testfunction (); & nbsp; this program uses global definition & nbsp; functiontes script ec (2); script
// $ Globals Array
Function testfunction (){
Echo $ globals ["php_self"];
}
Testfunction ();
// Global definition is used in this program
Function testfunction (){
Global $ s;
Echo $ s;
}
$ S = 'this is www.111cn.net ';
Testfunction ();
// Example of static variables
Function testfunction (){
Static $ mystr;
$ Mystr. = "111cn.net ";
Echo $ mystr ."
";
}
Testfunction (); // 111cn.net
Testfunction (); // 111cn.net111cn.net
Testfunction (); // 111cn.net111cn.net111cn.net
// Common variable
Function testfunction (){
$ Mystr. = "www.111cn.net ";
Echo $ mystr ."
";
}
Testfunction (); // www.111cn.net
// Let's briefly introduce the super global variables in php.
// $ GLOBALS contains a reference to a variable that is valid globally for each current script.
$ GLOBALS ['SITE'];
// $ _ SERVER variables are set by the web SERVER or directly associated with the execution environment of the current script
Echo $ _ SERVER ['document _ root'];
// $ _ Get url request the variable submitted to the script
Echo $ _ GET ['ac']
// $ _ POST the variables submitted to the script by the http post method
Echo $ _ POST ['AB']
// $ _ COOKIE the variables submitted to the script by the HTTP Cookies Method
Setcookie ('load', 'www .111cn.net ', time () + 3600*24,'/', '192. 168.0.110 ');
$ Cookis = $ _ COOKIE ['loaddomain '];
// $ _ FILES variables submitted to the script after the http post file is uploaded
Output value:
Print_r ($ _ FILES ['file']);
Array
(
[Name] => 45457.jpg
[Type] => image/pjpeg
[Tmp_name] => C: WINDOWSTempphpD7.tmp
[Error] => 0
[Size] = & gt; 10974
)
// $ _ ENV is not recommended
// $ _ REQUEST is submitted to the script variables by GET, POST, and COOKIE mechanisms. Therefore, this array is not safe and inefficient.
$ _ REQUEST ['bb '] // the data that will be automatically submitted is post, in the get form