php判断类的方法是否存在的方法:可以利用method_exists()函数进行判断。函数语法:【method_exists(mixed $object,string $method_name)】,如果方法在对象类中已定义,则返回TRUE。
method_exists()检查类的方法是否存在。如果 method_name 所指的方法在 object 所指的对象类中已定义,则返回 TRUE,否则返回 FALSE。
(推荐教程:php图文教程)
函数语法:
bool method_exists(mixed $object, string $method_name)
(视频教程推荐:php视频教程)
代码实现:
$directory=new Directory; if(!method_exists($directory,'read')){ echo '未定义read方法!'; }
以上就是php怎么判断类的方法是否存在的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1
| 本站CDN由 数掘科技 提供