3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private function do_something (bool $str) { echo "private function"; } public function call_something(A $obj) { //call_user_func([$obj, 'do_something'], true); $obj->do_something(true); } } class B extends A { public function do_something (string $value) { echo "subclass"; } } class C extends B { private function do_something (string $value) { echo "subclass"; } } $a = new A(); $c = new C(); $c->call_something($a);
Output for 7.4.0 - 7.4.33, 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: Access level to C::do_something() must be public (as in class B) in /in/UPRZC on line 22
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
Fatal error: Access level to C::do_something() must be public (as in class B) in /in/UPRZC on line 25
Process exited with code 255.
Output for 7.0.20
private function
Output for 7.0.0 - 7.0.6
Warning: Declaration of B::do_something(string $value) should be compatible with A::do_something(bool $str) in /in/UPRZC on line 19 private function
Output for 5.6.28
Catchable fatal error: Argument 1 passed to A::do_something() must be an instance of bool, boolean given, called in /in/UPRZC on line 11 and defined in /in/UPRZC on line 5
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
Strict Standards: Declaration of B::do_something() should be compatible with A::do_something(bool $str) in /in/UPRZC on line 19 Catchable fatal error: Argument 1 passed to A::do_something() must be an instance of bool, boolean given, called in /in/UPRZC on line 11 and defined in /in/UPRZC on line 5
Process exited with code 255.

preferences:
147.11 ms | 402 KiB | 182 Q