
ReflectionProperty::isDefault 메소드는 PHP의 ReflectionProperty 클래스에서 사용할 수 있는 메소드로, 지정된 속성이 기본 속성인지 여부를 확인합니다.
isDefault 메소드가 반환하는 boolean 값은 true이면 기본 속성이 아니고 false이면 기본 속성이란 의미입니다.
선생님, ReflectionProperty::isDefault 메소드가 반환하는 boolean 값이 true 인 경우, 속성이 선언된 곳에서 기본 속성으로 선언되지 않았을 때 true 값을 반환합니다.
선생님, ReflectionProperty::isDefault 메소드가 반환하는 boolean 값이 false 인 경우, 속성이 선언된 곳에서 기본 속성으로 선언되었을 때 false 값을 반환합니다.
선생님, 이 메소드의 사용 예시는 다음과 같습니다.
#hostingforum.kr
php
class Test {
public $defaultProperty = 'default';
public $nonDefaultProperty;
public function __construct() {
$this->nonDefaultProperty = 'nonDefault';
}
}
$reflectionClass = new ReflectionClass('Test');
$reflectionProperty = $reflectionClass->getProperty('defaultProperty');
echo $reflectionProperty->isDefault() ? 'true' : 'false'; // true
$reflectionProperty = $reflectionClass->getProperty('nonDefaultProperty');
echo $reflectionProperty->isDefault() ? 'true' : 'false'; // false
2025-08-07 05:40