判断 php 对象类型 是否有方法
3 回答
![?](http://img1.sycdn.imooc.com/54584e1f0001bec502200220-100-100.jpg)
冉冉说
TA贡献1877条经验 获得超1个赞
我们的中文真是博大精深呀,你的问题竟然隐藏两种含义:
1、如果是判断对象类型:
<?php
$a = 123;
//$a = function (){};
var_dump(gettype($a));
?>
使用自带函数: gettype
2、如果判断对象是否存在什么方法
<?php
class test {
function t(){
}
}
$a = new test();
var_dump(method_exists($a,'t'));
?>
使用函数:method_exists
- 3 回答
- 0 关注
- 2797 浏览
添加回答
举报
0/150
提交
取消