- var_dump: documentation ( source)
<?php
class Cl {
public function __get($n) {
if ($n === 'test') {
return null;
}
return $this->$n; // default fallback
}
public function __isset($n) {
if ($n === 'test') {
return true; // __isset() is the only way to return if property exists, returning true for null value violates isset() definition
}
return $this->$n; // default fallback
}
}
$cl = new Cl();
var_dump($cl->test);
var_dump(isset($cl->test));