PHP Data types and scope of variables

Source: Internet
Author: User
Tags type null

1) PHP supports basic data types as shown below:

An integer (integer), float (floating-point), String (String), Boolean (Boolean), Array (array), object, and two special types: null (empty), resource (Resource).

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

A specific built-in function, such as a database function, returns a variable of type resource.

2) Scopes are scopes that a variable can use or be visible in a script. PHP has 6 basic scope rules:

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

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

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

2.4) When a variable used inside a function is declared as a global variable, its name is the same as the global variable name;

2.5) A variable that is created inside a function and declared as static cannot be visible outside the function, but can be persisted during multiple executions of the function;

2.6) variables created inside the function are local to the function, and when the function terminates, the variable does not exist.

Note: The complete list of super global variables is as follows:

$GLOBALS--All global variable arrays;

$_server--server environment variable array;

$_get--the array of variables passed to the script by the GET method;

$_post--the array of variables passed to the script via the POST method;

An array of $_cookie--cookie variables;

$_files--array of variables related to file uploads;

An array of $_env--environment variables;

$_request--the array of variables entered by all users, including the input contained in $_get, $_post, and $_cookie;

An array of $_session--session variables.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

PHP Data types and scope of 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.