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.