What are global variables? Global variables are also called external variables, which are defined outside the function. Its scope starts from the place where the variable is defined and ends at the end of the program file. Unlike other programming languages, global variables are not automatically made available. In the previous chapter, we introduced local variables in the scope of PHP variables. In PHP, since functions can be regarded as separate program code fragments, local variables will override the visibility of global variables, so global variables cannot be called directly in the function. The code is in the following format:
##Introduction: Global variables are also called external variables. Defined outside the function, its scope starts from the variable definition to the end of the program file.
2. What are local variables? Detailed explanation of local variable examples in the scope of php variables
Introduction: The scope of a variable is also its effective scope. Most PHP variables have a single scope of use, including files introduced by include and require.
3. Detailed explanation of php variable functions and function reference and dereference examples
4.
Assignment of PHP variables: The difference between value passing and reference passing
5.
Detailed explanation of PHP variable scope examples
##Introduction: When using variables, they must comply with the variables Define the rules. Variables must be used within a valid range. If the variable exceeds the limited range, the variable will be meaningless. Just like if we have one hundred yuan, we can buy things within one hundred yuan. If the item exceeds one hundred yuan, , then the one hundred yuan cannot be used. One hundred dollars is equivalent to this variable, and the range within one hundred dollars is equivalent to the scope.
【Related Q&A recommendations】:
There is a variable in the php variable name
php variable Questions about objects
Ask me about the scope of php variables~~~
php references and php variables are not used
thinkPHP html template file, how to escape the curly brackets?
The above is the detailed content of Detailed introduction to PHP variables. For more information, please follow other related articles on the PHP Chinese website!