Learning Super global variables in php

Source: Internet
Author: User
Learning Super global variables in php
Since PHP 4.2.0, the default value of register_globals is off. as a result, many variables can be used directly in the past, for example, $ PHP_SELF or the set SESSION variable cannot be accessed in the form of "$ variable name", which may cause a lot of inconvenience, but may improve security.

Since PHP 4.2.0, the default value of register_globals is off. as a result, many variables can be used directly in the past, for example, $ PHP_SELF or the set SESSION variable cannot be accessed in the form of "$ variable name", which may cause a lot of inconvenience, but may 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'] original name (including path) of the client machine file ).

$ _ FILES ['myfile'] ['type'] indicates 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'] 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.

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.