PHP Super global variable _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Super global variables in PHP. The Super global variable in PHP starts from PHP4.2.0, and the default value of register_globals is off. as a result, many variables that can be directly used in the past can be used, for example, $ PHP_SELF or the hyperglobal variable in ses php you set starts from PHP 4.2.0, and the default value of register_globals is off. as a result, many previous variables that can be directly used are available, for example, $ PHP_SELF or the SESSION variable you set cannot be accessed in the form of "$ variable name". This may bring you a lot of changes, but it helps improve security. To access these variables, you need to use PHP hyper-global variables as follows:

$ _ SERVER
Variables are set by the Web server or directly associated with the execution environment of the current script. Similar to the old $ HTTP_SERVER_VARS array. The previous $ PHP_SELF corresponds to $ _ SERVER ['php _ SELF ']. you can use phpinfo to view your $ _ SERVER variable.

$ _ GET
Variables submitted to the script through the http get method. Similar to the old $ HTTP_GET_VARS array.

$ _ POST
Variables submitted to the script through the http post method. Similar to the old $ HTTP_POST_VARS array.

$ _ COOKIE
Variables submitted to the script through HTTP Cookies. Similar to the old $ HTTP_COOKIE_VARS array.

$ _ SESSION
The variable currently registered to the script session. Similar to the old $ HTTP_SESSION_VARS array.

$ _ FILES
Variables submitted to the script by uploading the http post file. Similar to the old $ HTTP_POST_FILES array.

$ _ ENV
Variables submitted to the script in the execution environment. Similar to the old $ HTTP_ENV_VARS array.

========================================================== ======================================
For the $ _ FILES variable: (the file field is "myfile ")

$ _ FILES ['myfile'] ['name']
The original name (including the path) of the client machine file ).

$ _ FILES ['myfile'] ['type']
The MIME type of the file, which must be supported by the browser, for example, "image/gif ".

$ _ FILES ['myfile'] ['size']
Size of the uploaded file, in bytes.

$ _ FILES ['myfile'] ['tmp _ name']
Temporary file name (including path) stored on the server after the file is uploaded ).

$ _ FILES ['myfile'] ['error']
The error code related to the file upload. ['Error'] is added in PHP 4.2.0.

When php. when register_globals in ini is set to on, $ myfile_name is equivalent to $ _ FILES ['myfile'] ['name'], $ myfile_type is equivalent to $ _ FILES ['myfile'] ['type.

Starting from ipv4.2.0, the default value of register_globals is off. as a result, many previous variables that can be directly used, such as $ PHP_SELF or your set SES...

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.