<?php
class ClassParent {
public function __construct() {
echo 'Im parent';
}
}
class ClassChild {
protected $parent = null;
public function __construct() {
echo 'Im child';
$this->parent = new parent();
}
}
new ClassChild();
Fatal error: Cannot use "parent" when current class scope has no parent in /in/3nmUi on line 16
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: Cannot use "parent" when current class scope has no parent in /in/3nmUi on line 16
Im child
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/3nmUi:16
Stack trace:
#0 /in/3nmUi(20): ClassChild->__construct()
#1 {main}
thrown in /in/3nmUi on line 16
Process exited with code 255.
Im child
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/3nmUi:16
Stack trace:
#0 /in/3nmUi(20): ClassChild->__construct()
#1 {main}
thrown in /in/3nmUi on line 16
Process exited with code 255.
Im child
Fatal error: Cannot access parent:: when current class scope has no parent in /in/3nmUi on line 16
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/3nmUi 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/3nmUi 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/3nmUi on line 4
Process exited with code 255.