What is static statically variable?
The static variable type descriptor is static.
Static variables are static storage, where the storage space is a static data area in memory (a storage unit is allocated in a static store), and the data in that region is occupied by the entire program during its run (not released during the entire run of the program) or its memory address is not changed. Until the end of the entire program runs (instead, the auto automatic variable, dynamic local variable, belongs to the dynamic storage category, which accounts for dynamic storage space, which is released after the function call ends). A static variable is always present throughout the execution of a program, but is not available outside its scope.
In addition, variables belonging to static storage are not necessarily static variables. For example, an external variable (a global variable in PHP) that is statically stored, but not necessarily static, must be defined by static to become a static external variable, or a static global variable.
All global variables are static variables, and local variables are local static variables only when they are defined with the type modifier static.
Static variables can be applied wherever they can be applied, and once the application is successful, it will no longer accept the same application.
A static variable does not mean that it cannot change the value, and the amount of the value cannot be changed is called a constant. The value it has is mutable, and it maintains the most recent value. It is static because it does not change as the function calls and exits. That is, when the function was last called, if we assign a value to a static variable, the value remains unchanged the next time the function is called.
The member variables of PHP can be initialized at the same time as the declaration, but only with scalar initialization.
For example:
Class A {public $f 1 = ' xxxx ', static public $f 2 = 100;}
If you want to assign a variable to an object, you can initialize it only in the constructor, for example:
Class A {private $child; public function construct () {$this->child = new B ();}}
But there is nothing in PHP that resembles a static constructor/static block in Java, and there is no right time to initialize it.
There are ways to resolve common members, such as:
Class A {static public $child;} A:: $child = new B ();
There seems to be no clean way for a private member to do this:
Class A {static private $child; static public Initialize () {self:: $child = new B ();}} A::initialize ();