Analyze the use of php variable modifier static. Static variables only exist in local function domains, but their values are not lost when the program runs out of this scope. Let's take a look at the following example: the Copy code: functiontest () {static variable only exists in a local function domain, but its value is not lost when the program runs out of this scope. Take a look at the following example:
The code is as follows:
Function test (){
Static $ a = 0;
$ A ++;
Echo $;
}
Test (); // 1
Test (); // 2
Test (); // 3
Note: static variables can be declared according to the preceding example. If a value is assigned to the expression result in the declaration, the parsing error occurs.
The code is as follows:
Static $ a = 0 + 1;
Static $ a = sqrt (121 );
As shown in the above assignment method, an error is reported. if you do not believe it, try it.
Bytes. Take a look at the following example: the code is as follows: function test () {static...