property_exists — 객체나 클래스가 프로퍼티를 가졌는지 확인 정보
PHP property_exists — 객체나 클래스가 프로퍼티를 가졌는지 확인본문
property_exists — 객체나 클래스가 프로퍼티를 가졌는지 확인
설명 :
bool property_exists ( mixed $class , string $property )
주어진 property가 지정한 클래스에 존재하는지 확인합니다.
Note:
isset()과 다르게, property_exists()는 프로퍼티가 NULL 값을 가지고 있어도 TRUE를 반환합니다.
인수 :
class
확인할 클래스명이나 클래스의 객체
property
프로퍼티명
반환값 :
프로퍼티가 존재하면 TRUE, 존재하지 않으면 FALSE, 오류시엔 NULL을 반환합니다.
예제 :
Example #1 property_exists() 예제
<?php
class myClass {
public $mine;
private $xpto;
static protected $test;
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')); //true, as of PHP 5.3.0
var_dump(property_exists('myClass', 'bar')); //false
var_dump(property_exists('myClass', 'test')); //true, as of PHP 5.3.0
myClass::test();
?>
0
댓글 0개