本文操作环境:windows10系统、PHP 7、thinkpad t480电脑。php判断类里面的某个方法是否存在:bool method_exists ( mixed $object , string $method_name ) 检查
本文操作环境:windows10系统、PHP 7、thinkpad t480电脑。
php判断类里面的某个方法是否存在:
bool method_exists ( mixed $object , string $method_name ) 检查类的方法是否存在,例如:
$directory=new Directory;
if(!method_exists($directory,'read')){
echo '未定义read方法!';
}
php 判断类里面的某个属性是否已经定义:
bool property_exists(mixed $class,string $property)检查类的属性是否存在,例如:
$directory=new Directory;
if(!property_exists($directory,'li')){
echo '未定义li属性!';
}
--结束END--
本文标题: php如何判断方法和属性是否存在
本文链接: https://www.lsjlt.com/news/360.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2023-05-25
2023-05-25
2023-05-25
2023-05-25
2023-05-25
2023-05-25
2023-05-25
2023-05-25
2023-05-25
2023-05-25
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0