Understanding and Using PHP Super global variable _ PHP Tutorial

Source: Internet
Author: User
Understand and use PHP Super global variables. Understanding and Using PHP Super global variable is also called pre-defined variable. it is a self-contained variable in the PHP System, which makes your program design more convenient and fast. Its types include understanding and using PHP Super global variables

Super global variables are also called pre-defined variables. they are self-contained variables in the PHP System. they make your program design more convenient and convenient. Its types include:

$ GLOBALS
Contains a reference to a variable that is valid globally for each current script. The key name of the array is the name of the global variable. $ GLOBALS array exists from PHP 3.
$ _ SERVER
Variables are set by the web server or directly associated with the execution environment of the current script. Similar to the old array
$ _ GET
Variables submitted to the script through URL requests.

$ _ POST
Variables submitted to the script through the http post method.
$ _ COOKIE
Variables submitted to the script through HTTP Cookies.
$ _ FILES
Variables submitted to the script by uploading the http post file.
$ _ ENV
Variables submitted to the script in the execution environment.
$ _ REQUEST
Variables submitted to the script through GET, POST, and COOKIE mechanisms.

$ _ SESSION
The variable currently registered to the script session.

The specific information is not explained here. you can create a php file and write the following code in the file.

The code is as follows:


Phpinfo ();
?>


And then you can see the following picture

On this page, you can view various types of super global variables in the system and apply them.
The following example shows how to use a php file to display the current file and the IP address of the current server.
The code is as follows:

The code is as follows:


Echo "the current file is". $ _ SERVER ["PHP_SELF"];
Echo"
";
Echo "the IP address of the current SERVER is:". $ _ SERVER ["SERVER_ADDR"];
?>


Through the above example, we found that the pre-defined variable, that is, the Super global variable, does not need to be defined during use (you can use phpinfo to query) and starts with "$, the variable names are all uppercase letters, and the corresponding parameters are enclosed in.

At this point, we will end the introduction of constant variables in PHP.
Magio's school is approaching the final exam, and it is estimated that the updates in the next few days will not be too timely. Sorry!

The extra super global variable is also called a predefined variable. it is a self-contained variable in the PHP System. it makes your program design more convenient and convenient. Its types include...

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.