zoukankan      html  css  js  c++  java
  • php get_called_class()函数与get_class()函数的区别

    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 

  • 相关阅读:
    解决ERROR C2011: 'FD_SET' : 'STRUCT' TYPE REDEFINITION问题
    github简单使用教程
    Win32 多线程的创建方法和基本使用
    day 05
    day04
    day03
    day02
    day 06
    day_05
    day 05
  • 原文地址:https://www.cnblogs.com/liuwanqiu/p/6736863.html
Copyright © 2011-2022 走看看