Local variables can be divided into dynamic and static storage types. Local variables in the function. if they are not specifically declared as static storage classes, they are dynamically allocated by default. The internal dynamic variables are automatically released after the function call is completed. If you want to keep the internal variables in the memory after the function is executed, you should use static variables. After the function is executed, the static variables will not disappear, but will be shared among all calls to the function. that is, when the function is executed again, the static variables will continue the operation for the previous consecutive result, and only in the script execution period... local variables can be divided into dynamic and static storage types. Local variables in the function. if they are not specifically declared as static storage classes, they are dynamically allocated by default. The internal dynamic variables are automatically released after the function call is completed. If you want to keep the internal variables in the memory after the function is executed, you should use static variables. After the function is executed, the static variables will not disappear, but will be shared among all calls to the function. that is, when the function is executed again, the static variables will continue the operation for the previous consecutive result, the function is initialized only when the function is called for the first time during script execution. To declare a function variable as static, use the keyword static. We have introduced the range of php variables to local variables and the range of php variables to global variables. Static variables can be applied in any place where they can be applied. Once the application is successful, it will no longer accept other applications. Static variables do not mean that they cannot change the value, and the amount of values that cannot be changed is a constant. Its value is variable, and it will keep the latest value. It is static because it does not change with the function call and exit. That is, the last call
1. differences between static local variables and static global variables
Introduction: local variables can be divided into dynamic and static storage types. Local variables in the function. if they are not specifically declared as static storage classes, they are dynamically allocated by default.
2. PHP source code learning-thread security
Introduction: in terms of scope, the C language can define four different variables: global variables, static global variables, local variables, and static local variables.
3. PHP kernel research static variable _ PHP Tutorial
Introduction: PHP kernel studies static variables. Static variables can be static global variables. If unset is not called, the static variables will exist until the program exits and are managed by Zend memory to release them.
4. what is the difference between static PHP global variables and common global variables?
Introduction: What is the difference between static PHP global variables and common global variables? In the preceding example, $ glo is globally scoped and the output result is different from the output result without the static keyword. it turns out that
5. PHP kernel research static variables
Introduction: PHP kernel studies static variables. Static variables can be static global variables. If unset is not called, the static variables will exist until the program exits and are managed by Zend memory to release them.
6. what is the difference between static PHP global variables and common global variables?
Introduction: What is the difference between static PHP global variables and common global variables? In the preceding example, $ glo is globally scoped and the output result is different from the output result without the static keyword. it turns out that
7. PHP static local variables and static global variables
Introduction: 1. it will not change with the function call and exit. However, although the variable still exists, it cannot be used. If you call the function that defines it again, it can continue to be used, and save the value left after the previous call 2. static local variables are initialized only once. static attributes can only be initialized as one character value or a constant and cannot be used.
The above are the details recommended by 7 articles on static php global variables. For more information, see other related articles in the first PHP community!