3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { private $vars; public function __get($name) { if (!isset($this->vars[$name])) { $arrObj = array(); $arrObj[] = new B(); $arrObj[] = new B(); $this->vars[$name] = $arrObj; } return $this->vars[$name]; } } class B { public $rolename = 'foo'; } $a = new A; var_dump($a); echo $a->role[0]->rolename.PHP_EOL; $a->role[0]->rolename = 'test'; echo $a->role[0]->rolename;
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
object(A)#1 (1) { ["vars":"A":private]=> NULL } foo Notice: Indirect modification of overloaded property A::$role has no effect in /in/9KlKt on line 28 test
Output for hhvm-3.10.0 - 3.12.0
object(A)#1 (1) { ["vars":"A":private]=> NULL } foo test
Output for 5.2.0 - 5.2.17
object(A)#1 (1) { ["vars:private"]=> NULL } foo Notice: Indirect modification of overloaded property A::$role has no effect in /in/9KlKt on line 28 test
Output for 5.0.4 - 5.1.6
object(A)#1 (1) { ["vars:private"]=> NULL } foo test
Output for 5.0.2 - 5.0.3
object(A)#1 (1) { ["vars:private"]=> NULL } foo Fatal error: Cannot access undefined property for object with overloaded property access in /in/9KlKt on line 28
Process exited with code 255.
Output for 5.0.0 - 5.0.1
object(A)#1 (1) { ["vars:private"]=> NULL } Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/9KlKt on line 27 fooPHP_EOL Fatal error: Cannot access undefined property for object with overloaded property access in /in/9KlKt on line 28
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/9KlKt on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9KlKt 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/9KlKt on line 4
Process exited with code 255.