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(foo $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 foo(); $c = new bar(); $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.19, 8.3.0 - 8.3.7
Fatal error: Access level to C::do_something() must be public (as in class B) in /in/CcP9v on line 22
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fatal error: Access level to C::do_something() must be public (as in class B) in /in/CcP9v on line 25
Process exited with code 255.
Output for 7.0.10 - 7.0.33
Fatal error: Uncaught Error: Class 'foo' not found in /in/CcP9v:28 Stack trace: #0 {main} thrown in /in/CcP9v on line 28
Process exited with code 255.
Output for 7.0.0 - 7.0.9
Warning: Declaration of B::do_something(string $value) should be compatible with A::do_something(bool $str) in /in/CcP9v on line 19 Fatal error: Uncaught Error: Class 'foo' not found in /in/CcP9v:28 Stack trace: #0 {main} thrown in /in/CcP9v on line 28
Process exited with code 255.
Output for 5.6.24 - 5.6.38
Fatal error: Class 'foo' not found in /in/CcP9v on line 28
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.23
Strict Standards: Declaration of B::do_something() should be compatible with A::do_something(bool $str) in /in/CcP9v on line 19 Fatal error: Class 'foo' not found in /in/CcP9v on line 28
Process exited with code 255.

preferences:
252.15 ms | 402 KiB | 295 Q