<?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));
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/GqUsh on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/GqUsh on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/GqUsh on line 4
Process exited with code 255.