辨析
new self();
new static();
参见
class A {
public static function get_self() {
return new self();
}
public static function get_static() {
return new static();
}
}
class B extends A {}
echo get_class(B::get_self()); // A
echo get_class(B::get_static()); // B
echo get_class(A::get_static()); // A
static是延迟绑定,就是说绑定在最后一次用的类上;而self在哪里面写就是指向哪个类的