
property_exists() 함수는 클래스의 속성이 존재하는지 여부를 확인하는 함수입니다. 이 함수는 true 또는 false를 반환하며, 속성의 실제 값을 반환하지 않습니다.
예를 들어, 다음 코드에서 property_exists() 함수는 Person 클래스의 속성이 'name' 이라는 이름으로 존재하는지 여부를 확인합니다.
#hostingforum.kr
php
class Person {
public $name;
public $age;
}
$person = new Person();
echo property_exists($person, 'name'); // true
echo property_exists($person, 'age'); // true
echo property_exists($person, 'email'); // false
property_exists() 함수는 클래스의 속성이 존재하는지 여부를 확인할 때 유용하게 사용할 수 있습니다.
2025-04-15 18:27