PHP get_class()函数调用示例
发布时间:2016-12-23 编辑:jiaochengji.com
本文介绍下,php中取得类实例信息的函数get_class的用法示例,有需要的朋友参考下吧。
php中get_class()函数的用法举例。
例子:
<?php /** * 学习get_class的用法 * edit by www.jbxue.com */ class Foo { function name_none_static(){ echo "My name is " . get_class() . "<br>"; echo "My name is " . get_class($this) . "<br>"; } } //类内部调用 $bar = new Foo(); $bar->name_none_static(); //类外部调用 echo "Its name is " . get_class($bar) . "<br>"; ?>
输出结果:
My name is Foo
My name is Foo
Its name is Foo
My name is Foo
Its name is Foo
您可能感兴趣的文章:
PHP get_class()函数调用示例
PHP get_class()函数的用法举例
php 反射函数举例
PHP创建对象的6种方式
php设计模式之单例模式学习
php反射机制用法详解
PHP函数库之类与对象详解
PHP面向对象中new self( )和 new static( ) 的区别
php interface_exists、class_exists、method_exists和property_exists介绍
实例详解php类中public,private,protected的区别
上一篇:php curl超时设置详解
下一篇:php记录蜘蛛爬行历史的实现代码
[关闭]