get_called_class

(PHP 5 >= 5.3.0, PHP 7)

get_called_class锟斤拷锟节撅拷态锟襟定o拷"Late Static Binding"锟斤拷锟斤拷锟斤拷锟斤拷锟�

说锟斤拷

get_called_class ( void ) : string

锟斤拷取锟斤拷态锟斤拷锟斤拷锟斤拷锟矫碉拷锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷疲锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫碉拷锟斤拷锟津返伙拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 get_called_class() 锟斤拷使锟斤拷

<?php

class foo {
    static public function 
test() {
        
var_dump(get_called_class());
    }
}

class 
bar extends foo {
}

foo::test();
bar::test();

?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

string(3) "foo"
string(3) "bar"

锟轿硷拷

  • get_parent_class() - 锟斤拷锟截讹拷锟斤拷锟斤拷锟侥革拷锟斤拷锟斤拷
  • get_class() - 锟斤拷锟截讹拷锟斤拷锟斤拷锟斤拷锟�
  • is_subclass_of() - 锟斤拷锟斤拷硕锟斤拷锟斤拷歉锟斤拷锟斤拷锟斤拷锟洁,锟津返伙拷 TRUE