property_exists
property_exists — オブジェクトもしくはクラスにプロパティが存在するかどうかを調べる
説明
bool property_exists ( mixed class, string property )この関数は、与えられたプロパティ property が 指定されたクラスに存在するかどうか (かつ現在のスコープからアクセス可能かどうか) を確認します。
注意: isset() とは対象的に、 プロパティの値が NULL の場合でも property_exists() は TRUE を返します。
パラメータ
- class
-
確認するクラス名、もしくはクラスのオブジェクトを指定します。
- property
-
プロパティ名を指定します。
返り値
プロパティが存在している場合は TRUE、存在していない場合に FALSE、 エラー時には NULL を返します。例
例 362. property_exists() の例
<?php
class myClass {
public $mine;
private $xpto;
static function test() {
var_dump(property_exists('myClass', 'xpto')); // ここからアクセス可能なので true
}
}
var_dump(property_exists('myClass', 'mine')); //true
var_dump(property_exists(new myClass, 'mine')); //true
var_dump(property_exists('myClass', 'xpto')); //public でないので false
myClass::test();
?>
参考
method_exists() |
Weblioに収録されているすべての辞書からproperty_existsを検索する場合は、下記のリンクをクリックしてください。

- property_existsのページへのリンク