<?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();
Warning: 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.
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 7.3.32 - 7.3.33
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.
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.
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.
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.