PHP Task Learning 4: Recognize and use PHP Super Global variables _php tutorial

Source: Internet
Author: User
Tags http cookie phpinfo
Recognize and use PHP Super global variables

The super global variable, also known as a predefined variable, is a self-contained variable in the PHP system, which makes your programming easier and faster. The types of this include:

$GLOBALS
Contains a reference to a globally valid variable that refers to each current script. The key name of the array is the name of the global variable. $GLOBALS array exists starting with 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
A variable that is submitted to the script via a URL request.

$_post
A variable that is submitted to the script via the HTTP POST method.
$_cookie
A variable that is submitted to the script via the HTTP cookie method.
$_files
A variable that is submitted to the script via an HTTP POST file upload.
$_env
Executes the variables that the environment submits to the script.
$_request
Variables that are submitted to the script via the Get,post and COOKIE mechanisms.

$_session
The variable currently registered to the script session.

Specifically, this information is not explained here, you can create a new PHP file, write the following code in the file.

Copy to ClipboardWhat to refer to: [www.bkjia.com] Phpinfo ()
?>

And execute, you can see the following screen:

In this page, you can see the various types of super global variables that exist in the system, so you can also apply it.

Here is an example of using a PHP file to display the current file and the IP address of the current server.

The code is as follows:

Copy to ClipboardWhat to refer to: [www.bkjia.com] echo "Current file is". $_server["Php_self"];
echo "
";
echo "The IP address of the current server is:". $_server["Server_addr"];
?>

From the above example, we find that the predefined variables, which are super global variables, are not defined when they are used (you can query by Phpinfo), and begin with "$_", the variable names are uppercase letters, and the corresponding parameters are enclosed with "[]".

Here, we're done with the constant variables in PHP.

Transferred from: http://www.cnblogs.com/walkbro/

http://www.bkjia.com/PHPjc/364488.html www.bkjia.com true http://www.bkjia.com/PHPjc/364488.html techarticle recognizing and using the PHP Super global variable Super global variable is also called a predefined variable, which is the variable that comes with the PHP system, which can make your programming easier and quicker. 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.