php检查类方法是否存在的方法是,使用method_exists方法来检查,例如【(method_exists($directory,'read'));】。
本文操作环境:windows10系统、php 7.3、thinkpad t480电脑。
method_exists检查类的方法是否存在。如果 method_name 所指的方法在 object 所指的对象类中已定义,则返回 true,否则返回 false。
代码示例:
<?php $directory = new Directory('.'); var_dump(method_exists($directory,'read')); ?><?php var_dump(method_exists('Directory','read')); ?>以上例程会输出:
bool(true)相关视频教程分享:php视频教程
以上就是php怎么检查类方法是否存在的详细内容!
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did38085
php怎么检查类方法是否存在
阅读:47次