美文网首页
php中的static和self

php中的static和self

作者: 142b7d823a09 | 来源:发表于2017-04-14 12:30 被阅读0次
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

相关文章

网友评论

      本文标题:php中的static和self

      本文链接:https://www.haomeiwen.com/subject/neywattx.html