本教程操作环境:windows7系统、PHP7.1版,DELL G3电脑在php中,可以使用method_exists()函数来判断类中是否定义了指定方法。示例:$directory=new Directory; if(!method_ex
本教程操作环境:windows7系统、PHP7.1版,DELL G3电脑
在php中,可以使用method_exists()函数来判断类中是否定义了指定方法。
示例:
$directory=new Directory;
if(!method_exists($directory,'read')){
echo '未定义read方法!';
}
说明:
method_exists()函数可以检查类的指定方法是否存在。语法:
method_exists(mixed $object, string $method_name): bool
该函数会检查类的方法是否存在于指定的 object中。
object:对象示例或者类名。
method_name:方法名。
--结束END--
本文标题: php怎么判断类中是否定义了指定方法
本文链接: https://www.lsjlt.com/news/212.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2023-09-28
2023-09-28
2023-09-28
2023-09-28
2023-09-28
2023-09-28
2023-09-28
2023-09-28
2023-09-28
2023-09-27
回答
回答
回答
回答
回答
回答
回答
0