Why are the results of this output CCC?
But that doesn't change the array?
And this will add elements to the array?
Static $arr = Array (), $arr [] = ' Sdsds '; $arr [] = ' xxx '; var_dump ($arr); static $arr = Array (' ww ', ' vv '); Var_dump ($arr);
I hope I can tell the principle:)
Reply content:
Why are the results of this output CCC?
But that doesn't change the array?
And this will add elements to the array?
Static $arr = Array (), $arr [] = ' Sdsds '; $arr [] = ' xxx '; var_dump ($arr); static $arr = Array (' ww ', ' vv '); Var_dump ($arr);
I hope I can tell the principle:)
Static is usually used in function or class, and this usage is less common.
I think that when the PHP engine sweeps to static, it will put the top of the mentioned domain in the static declaration
It becomes a
The next evolved into
The third one evolved into
Static variables are initialized before they are executed. No matter how many times it is initialized, it only works for the last time. You can assign a value without the static.
All of your
static $xxx = XXX;
Only one last sentence is useful.
The following code should be able to help you clarify the idea:
The result is:
Array (size=2) 0 = String ' gga ' (length=3) 1 = string ' Gaga ' (length=4)
The second second defines the array as empty and should be ignored.
You change the second definition of the first to "' and see the results."
Learn the ...