魏长东

weichangdong

东邪

php get_class vs get_called_calss

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

class bar  extends  foo {
}

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

echo "====================\n\n";

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

class  bar2  extends  foo2  {
}

foo2::test();
bar2::test();

run result

string(3) "foo" string(3) "foo" 
==================== 
string(4) "foo2" string(4) "bar2"