Php Data type and variable scope

Source: Internet
Author: User
Php Data type and variable scope 1) php supports the following basic data types:

Integer, Float, String, Boolean, Array, and Object. In addition, there are two special types: NULL or resource ).

Note: a variable that is not assigned a value, has been reset, or has been assigned a special value of NULL is a NULL variable.

A specific built-in function (such as a database function) will return a variable of the resource type.

2) scope refers to the range in which a variable can be used or visible in a script. PHP has six basic scope rules:

2.1) built-in Super global variables can be used and visible anywhere in the script;

2.2) constants, once declared, can be globally visible;

2.3) the global variables declared in a script are visible throughout the script;

2.4) when the variable used in the function is declared as a global variable, its name must be consistent with the global variable name;

2.5) variables created and declared as static within the function cannot be visible outside the function, but this value can be kept during multiple function executions;

2.6) the variable created in the function is local to the function. when the function is terminated, the variable does not exist.

Note: The Complete List of Super global variables is as follows:

$ GLOBALS ?? All global variable arrays;

$ _ SERVER ?? Array of server environment variables;

$ _ GET ?? The variable array passed to the script through the GET method;

$ _ POST ?? Array of variables passed to the script through the POST method;

$ _ COOKIE ?? Cookie variable array;

$ _ FILES ?? Array of variables related to file upload;

$ _ ENV ?? Environment variable array;

$ _ REQUEST ?? An array of all input variables, including $ _ GET, $ _ POST, and $ _ COOKIE;

$ _ SESSION ?? An array of session variables.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.