The reason for using a static local variable is that it cannot be used externally, but its value is still retained after it has not been used. Although using global variables can achieve the same functionality, it often causes unexpected
Characteristics of static local variables: 1. Will not change as the function is invoked and exited, however, although the variable continues to exist, it cannot be used. If the function that defines it is invoked again, it can continue to use and save the value 2 that was left after the last invocation. Static local variables are initialized only once 3. Static properties can only be initialized to a character value or a constant and cannot use an expression. The system automatically assigns an initial value of 0 (to a numeric variable) or a null character (to a character variable), even if the local static variable is defined without an initial initializer, and a static variable is initially 0. 4. When you call a function multiple times and require the values of certain variables to be preserved between calls, consider the use of static local variables. Although the above goal can be achieved with global variables, global variables sometimes cause unexpected side effects, so it is advisable to adopt local static variables. The code is as follows: function test () {Static $var = 5; static $var = 1+1; it will error $var + +; Echo $var. ' '; Test (); 2 test (); 3 Test (); 4 echo $var; Error: notice:undefined variable:var about static global variables: The code is as follows://The global variable itself is a static storage mode, all global variables are static variable function Static_global () {g Lobal $glo; $glo + +; echo $glo. ' <br> '; } static_global (); 1 Static_global (); 2 Static_global (); 3 echo $glo. ' <br> '; 3 so static global variables are not used much.