I read the book and said: static members are always unique and can be shared among multiple objects.
Therefore, if I. person is instantiated in PHP. class. PHP class and assign a value to static $ name. if this class is instantiated again in PHP, can B not read the new value of the name attribute?
The Code is as follows:
Person. Class. php
<span style="font-size:14px;"><?php class person{ public static $name; function __construct($name='vv'){ //self::$name = $name; } function getName(){ return self::$name; } }?></span>
A. php
<span style="font-size:14px;"><?php include 'Person.class.php'; $ren = new Person(); Person::$name = 'aa'; echo $ren -> getName(); //aa $ren2 = new Person(); echo $ren2 -> getName(); //aa?></span>
B. php
<span style="font-size:14px;"><?php include 'Person.class.php'; $ren3 = new Person(); echo $ren3 -> getName(); //null?></span>
It turns out that static members can only be shared among multiple objects in the same script. B. PHP cannot read. the property value set by PHP was taken for granted. Because PHP can enable multiple processes to execute the script at the same time, and the memory is automatically released after the script is executed, B. PHP cannot read. PHP properties!
Complete static usage instructions: see PHP details page 284th.