3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function run() { return call_user_func(array('Bar', 'getValue')); } private function getValue() { return 'Foo'; } } class Bar extends Foo { public static function getValue() { return 'Bar'; } } $x = new Bar; echo $x->run();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
Bar
Output for 5.3.0 - 5.3.20, 5.4.0 - 5.4.10
Fatal error: Cannot make non static method Foo::getValue() static in class Bar in /in/k3DJM on line 21
Process exited with code 255.

preferences:
82.55 ms | 402 KiB | 59 Q