3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class MyClass { protected $data = array('some' => array('sub' => 'data')); public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if (is_scalar($this->data[$name])) { $property = $this->data[$name]; } else { $property = &$this->data[$name]; } return $property; } } $my = new MyClass(); $my->some['sub'] = 'test'; // пытаемся изменить значение echo $my->some['sub']; // выведет 'data'
Output for 5.2.1 - 7.1.0
Notice: Indirect modification of overloaded property MyClass::$some has no effect in /in/XoLsB on line 24 data
Output for 5.0.4 - 5.0.5, 5.1.1 - 5.2.0
data
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/XoLsB on line 26
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Fatal error: Cannot access undefined property for object with overloaded property access in /in/XoLsB on line 24
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/XoLsB on line 3
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/XoLsB on line 3
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/XoLsB on line 3
Process exited with code 255.