get_class (): 获取当前调用方法的类名; 
get_called_class():获取静态绑定后的类名;
class Foo{
      public function test(){
         var_dump(get_class());
      }

      public function test2(){
        var_dump(get_called_class());
      }

      public static function test3(){
        var_dump(get_class());
      }

      public static function test4(){
        var_dump(get_called_class());
      }
   }

   class B extends Foo{

   }

   $B=new B();
   $B->test();
   $B->test2();
   Foo::test3();
   Foo::test4();
   B::test3();
   B::test4();

  

输出结果:
string 'Foo' (length=3)
string 'B' (length=1)
string 'Foo' (length=3)
string 'Foo' (length=3)
string 'Foo' (length=3)
string 'B' (length=1)

 转自:http://blog.csdn.net/tashanhongye/article/details/48159771 

相关文章:

  • 2022-12-23
  • 2021-08-01
  • 2021-06-09
  • 2021-12-10
  • 2022-12-23
  • 2021-05-29
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-11-02
  • 2022-02-18
相关资源
相似解决方案