<?php
class zOMG
{
public function __get($name)
{
if (!isset($this->$name)) {
$this->$name = new self;
}
return $this->$name;
}
public function __set($name, $value)
{
$this->$name = $value;
}
}
$foo = new zOMG();
$foo->a->b = 1;
var_dump($foo);
Deprecated: Creation of dynamic property zOMG::$a is deprecated in /in/MtNt3 on line 14
Deprecated: Creation of dynamic property zOMG::$b is deprecated in /in/MtNt3 on line 14
object(zOMG)#1 (1) {
["a"]=>
object(zOMG)#2 (1) {
["b"]=>
int(1)
}
}
Fatal error: Cannot access undefined property for object with overloaded property access in /in/MtNt3 on line 19
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/MtNt3 on line 5
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/MtNt3 on line 5
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/MtNt3 on line 5
Process exited with code 255.