3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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;
based on qvITi
Output for 7.1.0 - 7.2.0
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.4.10 - 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
Output for 5.3.20 - 5.3.29
Strict Standards: Declaration of B::getMessage() should be compatible with that of A::getMessage() 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