Home > Article > Backend Development > Detailed explanation of PHP variable scope (1/3)_PHP tutorial
The scope of a variable is the context in which it is defined (that is, the scope in which it takes effect). Most PHP variables have only a single scope. This single scope span also includes files introduced by include and require.
For example:
The code is as follows | Copy code | ||||||||
include 'b.inc';?>
|
The code is as follows | Copy code | ||||||||
$a = 1; /* global scope */
} Test(); ?>
First, an example of using global: Example #1 Using global Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn Previous article:Implementing asynchronous calling of multi-threaded program code in PHP_PHP tutorialNext article:Implementing asynchronous calling of multi-threaded program code in PHP_PHP tutorial Related articlesSee more |