Home  >  Article  >  Backend Development  >  7 recommended articles about PHP static global variables

7 recommended articles about PHP static global variables

伊谢尔伦
伊谢尔伦Original
2017-06-11 09:19:511198browse

Local variables can be divided into dynamic storage types and static storage types in terms of storage methods. Local variables in a function, unless specifically declared as static storage class, will allocate storage space dynamically by default. The internal dynamic variables are automatically released after the function call. If you want the internal variables to remain in 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 to operate from the previous results, and will only be used during the execution of the script. The period function is initialized the first time it is called. To declare a function variable as static, you need to use the keyword static. Earlier we introduced the local variables in the scope of PHP variables and the global variables in the scope of PHP variables. Static variables can be applied anywhere. Once the application is successful, it will no longer accept other similar applications. A static variable does not mean that it cannot change its value. A quantity that cannot change its value is called a constant. The value it holds is mutable, and it will remain up-to-date. It is said to be static because it does not change when the function is called or exits. That is, the last call

1. Detailed explanation of the difference between static static local variables and static global variables

7 recommended articles about PHP static global variables

Introduction: Local variables can be divided into dynamic storage types and static storage types in terms of storage methods. Local variables in a function, unless specifically declared as static storage class, will allocate storage space dynamically by default.

2. PHP source code learning thread safety

Introduction: In terms of scope, C language can be defined 4 different kinds of variables: global variables, static global variables, local variables, static local variables.

3. PHP kernel research static variables_PHP tutorial

Introduction: PHP kernel research static variables. Static variables can be static global variables. If unset is not called, then this static variable will always exist until the program exits when it is released by Zend memory management. It can be static local

## 4. What is the difference between PHP static global variables and ordinary global variables?

Introduction: What is the difference between PHP static global variables and ordinary global variables? In the above example $glo is Global scope, and the output results are different with and without the static keyword. It turns out that it can be used

5. PHP kernel research static variables

Introduction: PHP kernel studies static variables. Static variables can be static global variables. If unset is not called, then this static variable will always exist until the program exits when it is released by Zend memory management. It can be static local

## 6.

What is the difference between PHP static global variables and ordinary global variables?

Introduction: What is the difference between PHP static global variables and ordinary global variables? In the above example $glo is Global scope, and the output results are different with and without the static keyword. It turns out that it can be used

7.

PHP static static local variables and static global variables Summary

Introduction: 1. It will not change as the function is called and exits. However, although the variable continues to exist, it cannot be used. If the function that defines it is called again, it can continue to be used, and the value left after the previous call is saved. 2. Static local variables will only be initialized once. 3. Static properties can only be initialized to a character value or a Constant, cannot use

The above is the detailed content of 7 recommended articles about PHP static global variables. For more information, please follow other related articles on the PHP Chinese website!

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