3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class B { public function __get($name) { $this->__set($name, new C); return $this->$name; } public function __set($name, $value) { $this->$name = $value; } } class C { public function test() { return new D; } } class D { public $d; } $b = new B; $b->c->test()->d = 'waa'; echo 'first call success' . PHP_EOL; $b->c->test(); echo 'just a call to test() works' . PHP_EOL; $b->c->test()->d = 'waa'; echo 'second call success' . PHP_EOL;
Output for 5.0.2 - 7.1.0
first call success just a call to test() works second call success
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/bMKbI on line 33 first call successPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/bMKbI on line 36 just a call to test() worksPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/bMKbI on line 39 second call successPHP_EOL
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/bMKbI on line 5
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/bMKbI 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/bMKbI on line 5
Process exited with code 255.