<?php
class A {
public $classB, $classC;
public function __construct(){
// Do stuff that should only be initialized once
// Then later :
$this -> classB = new B();
$this -> classC = new C();
}
}
Class B {
public function __construct(){
}
public function sayHi() {
echo 'hi';
}
}
Class C extends A {
public function __construct() {
$this -> classB -> sayHi();
}
}
$test = new A();
Fatal error: Uncaught Error: Call to a member function sayHi() on null in /in/SVBNm:25
Stack trace:
#0 /in/SVBNm(9): C->__construct()
#1 /in/SVBNm(29): A->__construct()
#2 {main}
thrown in /in/SVBNm on line 25
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Fatal error: Call to a member function sayHi() on null in /in/SVBNm on line 25
Process exited with code 255.
Fatal error: Call to a member function sayHi() on a non-object in /in/SVBNm on line 25
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/SVBNm on line 3
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/SVBNm 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/SVBNm on line 3
Process exited with code 255.