php判断类方法是否存在的方法:可以使用method_exists()函数来判断,具体使用方法如:【method_exists($directory,'read')】。method_exists()函数检查类的方法是否存在
php判断类方法是否存在的方法:可以使用method_exists()函数来判断,具体使用方法如:【method_exists($directory,'read')】。method_exists()函数检查类的方法是否存在于指定的对象中。
函数定义:
(推荐教程:php图文教程)
method_exists()函数检查类的方法是否存在于指定的 object中。如果 method_name 所指的方法在 object 所指的对象类中已定义,则返回 TRUE,否则返回 FALSE。
函数语法:
bool method_exists ( mixed $object , string $method_name )
(视频教程推荐:php视频教程)
代码实现:
$directory=new Directory; if(!method_exists($directory,'read')){ echo '未定义read方法!'; }
免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:operations@xinnet.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。