3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test2 { public function getSomething() { return "something"; } } class Test1 { private $test2; public function __construct($test2) { $this->test2=$test2; } public function getTest2() { return $this->_test2; } } $test1=new Test1(new Test2()); echo $test1->getTest2()->getSomething();
Output for 7.0.0 - 7.1.0
Notice: Undefined property: Test1::$_test2 in /in/cbgdv on line 17 Fatal error: Uncaught Error: Call to a member function getSomething() on null in /in/cbgdv:23 Stack trace: #0 {main} thrown in /in/cbgdv on line 23
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined property: Test1::$_test2 in /in/cbgdv on line 17 Fatal error: Call to a member function getSomething() on null in /in/cbgdv on line 23
Process exited with code 255.
Output for 5.2.6 - 5.5.35
Notice: Undefined property: Test1::$_test2 in /in/cbgdv on line 17 Fatal error: Call to a member function getSomething() on a non-object in /in/cbgdv on line 23
Process exited with code 255.
Output for 5.0.0 - 5.2.5
Notice: Undefined property: Test1::$_test2 in /in/cbgdv on line 17 Fatal error: Call to a member function getSomething() on a non-object in /in/cbgdv on line 23
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/cbgdv 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/cbgdv 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/cbgdv on line 4
Process exited with code 255.