3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A{ private $__props = ["a"]; function __get($prop){ if(\array_key_exists($prop, $this->__props)){ return $this->__props[$prop]; } } function __set($prop, $value){ if($prop === "a"){ if($value > 100){ $this->__props[$prop] = $value; } else { trigger_error('Invariant "$this->a > 100" violated'); } } } } $a = new A(); $a->a = 110; $b = &$a->a; $b = "hello"; var_dump($a,$b);
based on oc9XJ
Output for 5.4.0 - 7.2.0
Notice: Indirect modification of overloaded property A::$a has no effect in /in/ctX1c on line 22 object(A)#1 (1) { ["__props":"A":private]=> array(2) { [0]=> string(1) "a" ["a"]=> int(110) } } string(5) "hello"
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/ctX1c on line 4
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/ctX1c on line 4
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/ctX1c 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/ctX1c 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/ctX1c on line 4
Process exited with code 255.