<?php
class MainClass
{
public $variable;
public function __construct($variable)
{
$this->variable = $variable;
}
public function getVariable()
{
var_dump($this->variable);
}
}
class ChildClass extends MainClass
{
public function method()
{
$this->getVariable();
}
}
$foo = new MainClass('value');
$bar = new ChildClass();
$bar->method();
?>
Fatal error: Uncaught ArgumentCountError: Too few arguments to function MainClass::__construct(), 0 passed in /in/q73n7 on line 27 and exactly 1 expected in /in/q73n7:7
Stack trace:
#0 /in/q73n7(27): MainClass->__construct()
#1 {main}
thrown in /in/q73n7 on line 7
Process exited with code 255.
Warning: Missing argument 1 for MainClass::__construct(), called in /in/q73n7 on line 27 and defined in /in/q73n7 on line 7
Notice: Undefined variable: variable in /in/q73n7 on line 9
NULL
Output for 5.0.0 - 5.0.5
Warning: Missing argument 1 for MainClass::__construct() in /in/q73n7 on line 7
NULL
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/q73n7 on line 5
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/q73n7 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/q73n7 on line 5
Process exited with code 255.