
1. property_exists 함수는 PHP에서 특정 객체의 속성을 확인하는 데 사용되는 내장 함수입니다.
2. property_exists 함수는 객체의 속성을 확인하고, 속성이 존재하는지 여부를 boolean 값으로 반환합니다.
3. 예시를 들어보겠습니다.
#hostingforum.kr
php
class Person {
public $name;
public $age;
function __construct($name, $age) {
$this->name = $name;
$this->age = $age;
}
}
$person = new Person('John', 30);
echo property_exists($person, 'name') ? 'true' : 'false'; // true
echo property_exists($person, 'age') ? 'true' : 'false'; // true
echo property_exists($person, 'city') ? 'true' : 'false'; // false
4. property_exists 함수는 주어진 객체에 특정 속성이 존재하는지 확인하기 위해 사용됩니다.
5. property_exists 함수가 주어진 객체에 속성이 존재하지 않으면 false를 반환합니다.
2025-08-03 06:18