相关函数:
(学习视频推荐:java课程)
bool method_exists ( mixed $object , string $method_name ) 检查类的方法是否存在
代码示例:
$directory=new Directory;
if(!method_exists($directory,'read')) {
echo '未定义read方法!';
}如果要判断类里面的某个属性是否已经定义,在使用如下方法:
bool property_exists ( mixed $class , string $property )检查类的属性是否存在
代码示例:
$directory=new Directory;
if(!property_exists($directory,'li')) {
echo '未定义li属性!';
}
Copyright © 2019- itiz.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务