3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $message = 'breaks'; public function __construct() { } public function getMessage($type) { return $this->message; } } class B extends A { public function __construct($message) { parent::__construct(); $this->message = $message; } public function getMessage($type, $extra) { return $this->message; } } $o = new B('works'); echo $o->getMessage() . PHP_EOL;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Declaration of B::getMessage($type, $extra) must be compatible with A::getMessage($type) in /in/uKQM4 on line 21
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of B::getMessage($type, $extra) should be compatible with A::getMessage($type) in /in/uKQM4 on line 21 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::getMessage(), 0 passed in /in/uKQM4 on line 27 and exactly 2 expected in /in/uKQM4:21 Stack trace: #0 /in/uKQM4(27): B->getMessage() #1 {main} thrown in /in/uKQM4 on line 21
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33
Warning: Declaration of B::getMessage($type, $extra) should be compatible with A::getMessage($type) in /in/uKQM4 on line 24 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::getMessage(), 0 passed in /in/uKQM4 on line 27 and exactly 2 expected in /in/uKQM4:21 Stack trace: #0 /in/uKQM4(27): B->getMessage() #1 {main} thrown in /in/uKQM4 on line 21
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Declaration of B::getMessage($type, $extra) should be compatible with A::getMessage($type) in /in/uKQM4 on line 24 Warning: Missing argument 1 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21 Warning: Missing argument 2 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21 works
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Declaration of B::getMessage() should be compatible with A::getMessage($type) in /in/uKQM4 on line 24 Warning: Missing argument 1 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21 Warning: Missing argument 2 for B::getMessage(), called in /in/uKQM4 on line 27 and defined in /in/uKQM4 on line 21 works

preferences:
156.23 ms | 402 KiB | 183 Q