Scope and lifetime of PHP variables

Source: Internet
Author: User
Tags php script

To modify a PHP system, only to find that the scope and lifetime of the PHP variable is very different, this record has been consulted:

The main variables in PHP scripts are: Built-in super global variables, general variables, constants, global variables, static variables and so on;

1. Built-in super global variables can be used and visible anywhere in the script. That is, if we change one of the values in a PHP page, the value of the other PHP page will change as well.

The complete list of super global variables is as follows:
1. $GOBALS all global variable arrays
2.$_server Server environment variable array
3.$_post array of variables passed to the script via the POST method
4.$_get An array of variables passed to the script by the GET method
5.$_cookie array of COOKIE variables
6.$_files array of variables related to file uploads
7. $ENV An array of environment variables
8.$_request array of variables entered by all users includes input $_get $_post $_cookie
9.$_session Session Variable Array

2. Once the constants are declared, they can be globally visible, that is, they can be used inside and outside the function, but this is limited to a single page (containing the PHP script that we included through include and include_once), but it is not available in other pages. you must remember to refer to the page of the declaration .

Scope and lifetime of PHP variables

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.