PHP中的property_exists()函数
property_exists()方法检查对象或类是否具有属性。
语法
property_exists(object, property)
参数
object/class-对象或类名
property-属性的名称
返回
如果属性存在,property_exists()函数将返回TRUE,如果属性不存在,则返回FALSE,如果发生错误,则返回NULL。
示例
以下是一个例子-
<?php
class Demo {
public $one;
private $two;
static protected $VAL;
static function VAL() {
var_dump(property_exists('myClass', 'two'));
}
}
var_dump(property_exists('Demo', 'one'));
var_dump(property_exists(new Demo, 'one'));
?>输出结果
以下是输出-
bool(true) bool(true)
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练