Take a look at the Late Static Bindings of PHP5.3 and briefly translate it
Late Static Bindings is a new feature added in PHP5.3. In Pinyin, it is an expression that was originally fixed in the definition stage.
or variables are changed during the execution phase. For example, when a subclass inherits the static expression of the parent class, its value cannot be changed. You do not want to see this situation when there is
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
self::who( :) );//Input A
?>
But now I want it to output B, so this feature can be achieved using Late Static Bindings
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
static::who(); // Late Static Bindings
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test();//Output B
?>
http://www.bkjia.com/PHPjc/508358.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/508358.html