本文总结了php类和对象相关系统函数与运算符。分享给大家供大家参考,具体如下:
系统函数
class_exists() 判断某个类是否存在
interface_exists() 判断接口是否存在
get_class() / class 获取某个对象所处的类名
get_parent_class() 获取某个对象所属父类的类名
get_class_methods() 获取一个类所有方法,返回索引数组
get_class_vars() 获取一个类所有属性,下标为属性名
get_declared_classes() 获取所有声明过的类(包括系统类)
is_object() 判断是否对象
get_object_vars() 获得对象所有属性,返回数组,下标为属性名
property_exists() 判断对象中是否存在该属性
method 获得方法名
function 获得函数名
运算符
new 实例化一个对象
instanceof 判断一个对象是否某个类(包括继承)的实例
class bee{} $o = new bee(); if($o instanceof bee){ echo 'true'; }
以上就是php类和对象相关系统函数与运算符小结的详细内容。
