首页  >  文章  >  后端开发  >  php get_class()函数

php get_class()函数

WBOY
WBOY原创
2016-08-08 09:28:473082浏览

<span>php  
  
</span><span>class</span><span> Car {  
      
    </span><span>function</span><span> getName(){  
        </span><span>echo</span> "My name is " . <span>get_class</span>() . "<br>"<span>;  
        </span><span>echo</span> "My name is " . <span>get_class</span>(<span>$this</span>) . "<br>"<span>;  
    }  
}  
  
</span><span>//</span><span>类内部调用  </span>
<span>$bar</span> = <span>new</span><span> Car();  
</span><span>$bar</span>-><span>getName();  
  
</span><span>//</span><span>类外部调用  </span>
<span>echo</span> "Its name is " . <span>get_class</span>(<span>$bar</span>) . "<br>"<span>;  
  
</span>?>   

运行结果

My name is Car

My name is Car
Its name is Car

以上就介绍了php get_class()函数,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn