<?php
class A {
protected $db;
protected $host;
protected $user = 'foo';
public function __construct($database, $host = 'localhost') {
$this->host = $host;
$this->connect();
}
public function connect() {
echo "connected to ".$this->db." and ".$this->host."\n";
}
}
class B extends A {
function example() {
echo "Called example()\n";
}
}
$b = new B;
$b->example();
?>
Fatal error: Uncaught ArgumentCountError: Too few arguments to function A::__construct(), 0 passed in /in/sI6RN on line 23 and at least 1 expected in /in/sI6RN:7
Stack trace:
#0 /in/sI6RN(23): A->__construct()
#1 {main}
thrown in /in/sI6RN on line 7
Process exited with code 255.
Warning: Missing argument 1 for A::__construct(), called in /in/sI6RN on line 23 and defined in /in/sI6RN on line 7
connected to and localhost
Called example()
Output for 5.0.0 - 5.0.5
Warning: Missing argument 1 for A::__construct() in /in/sI6RN on line 7
connected to and localhost
Called example()
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/sI6RN 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/sI6RN 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/sI6RN on line 3
Process exited with code 255.