Php pre-defined variables

Source: Internet
Author: User
PHP provides a large number of predefined variables. Because many variables depend on the version and settings of the running server, and other factors, there is no detailed description document. Some predefined variables do not take effect when PHP is run as a command line. PHP provides a large number of predefined variables. Because many variables depend on the version and settings of the running server, and other factors, there is no detailed description document. Some predefined variables do not take effect when PHP is run as a command line.

Warning

In PHP 4.2.0 and later versions, the default value of the PHP command register_globals is off. This is a major change in PHP. Setting the value of register_globals to off affects the validity of the predefined variable set within the global range. For example, to obtain the DOCUMENT_ROOT value, you must use $ _ SERVER ['document _ root'] instead of $ DOCUMENT_ROOT, as shown in the following figure, use $ _ GET ['id'] instead of $ id from URL http://www.example.com/test.php? In id = 3, get the id value, or use $ _ ENV ['home'] instead of $ HOME to get the value of the environment variable HOME.

If there are available PHP pre-defined variables, it is best to use them, such as ultra-Global arrays.

Starting from PHP 4.1.0, PHP provides an additional set of pre-defined arrays that contain data from the web server (if available), runtime environment, and user input. These arrays are very special and they take effect globally, for example, automatically within any range. Therefore, it is usually called autoglobals or superglobals ). (PHP does not have a mechanism for customizing global variables .) Hyperglobal variables are listed below. For more information about them, PHP predefined variables, and their nature, see predefine variables. In addition, you will also notice that the old pre-defined array ($ HTTP _ * _ VARS) still exists. From PHP 5.0.0, you can use register_long_arrays to disable long PHP pre-defined variable arrays.

Note: variable

Super global variables cannot be used as variable variables in functions or class methods.

Note:

Although the hyper-global variables and HTTP _ * _ VARS both exist, they are not the same variable. Therefore, changing one value does not affect the other.

If some variables in variables_order are not set, their corresponding PHP pre-defined arrays are also empty.

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.