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();
?>
'IT > php' 카테고리의 다른 글
php get_declared_interfaces — 선언된 모든 인터페이스의 배열을 반환 (0) | 2017.01.13 |
---|---|
get_declared_classes — 선언된 클래스명을 배열로 반환 (0) | 2017.01.13 |
php trait_exists — 형질이 존재하는지 검사한다. (0) | 2017.01.12 |
php is_subclass_of — 이 클래스가 부모 클래스의 자식인지 확인 (0) | 2017.01.12 |
php is_a — 객체가 이 클래스나 부모 클래스 중 하나인지 확인 (0) | 2017.01.11 |