__isset() Method¶
__isset()
is a magic method : it is called when the existence of a property has to be checked.
That way, it is possible to create dynamically properties, without hardcoding them.
The __isset() method is usually paired with the __get() and __set() methods.
<?php
class x {
private $values = ['a' => 1,
'b' => 2,
];
function __isset($name) {
return isset($this->values[$name]);
}
}
?>
Related : Magic Methods, __set() Method, __get() Method