3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { } class A { public function b(/* C */ $c) { echo 'c'; } } class B extends A { public function b(C $c) { echo 'd'; } } $c = new C(); $b = new B(); echo $b->b($c);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Declaration of B::b(C $c) must be compatible with A::b($c) in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/HPrqa on line 13 Warning: Declaration of B::b(C $c) should be compatible with A::b($c) in /in/HPrqa on line 14 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/HPrqa on line 20 and exactly 1 expected in /in/HPrqa:14 Stack trace: #0 /in/HPrqa(20): B->b() #1 {main} thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/HPrqa on line 20 and exactly 1 expected in /in/HPrqa:14 Stack trace: #0 /in/HPrqa(20): B->b() #1 {main} thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/HPrqa on line 13 Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::b(), 0 passed in /in/HPrqa on line 20 and exactly 1 expected in /in/HPrqa:14 Stack trace: #0 /in/HPrqa(20): B->b() #1 {main} thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in /in/HPrqa on line 13 Fatal error: Uncaught TypeError: Argument 1 passed to B::b() must be an instance of C, none given, called in /in/HPrqa on line 20 and defined in /in/HPrqa:14 Stack trace: #0 /in/HPrqa(20): B->b() #1 {main} thrown in /in/HPrqa on line 14
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Catchable fatal error: Argument 1 passed to B::b() must be an instance of C, none given, called in /in/HPrqa on line 20 and defined in /in/HPrqa on line 14
Process exited with code 255.

preferences:
184.18 ms | 401 KiB | 286 Q