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
##Introduction: Variable functions are supported in PHP. First define some functions, then declare a variable, use the variable to call different functions, and then continuously reassign the variable. Below we will introduce the specific use of variable functions through an example.
4.
Assignment of PHP variables: The difference between value passing and reference passing
Introduction: A variable refers to the amount that the value can change during the execution of the program. It is used to save a value so that we can call it conveniently. However, there are two ways to assign values to variables in PHP. : Pass by value and pass by reference, these two methods of assigning values to variables are different. In this chapter, we will lead you to understand: the difference between pass by value and pass by reference
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!