Late Static Bindings是在PHP
或變量
時不希望看到這種情況
<?php
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
self::who();
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test();//輸入A
?>
但是現在我想讓其輸出B
<?php
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();//輸出B
?>
From:http://tw.wingwit.com/Article/program/PHP/201404/30629.html