3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function testIsCallable(callable $param) { return is_callable($param); } private function privateMethod() { echo "This is a private method"; } public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } class B extends A { public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } $a = new A(); $b = new B(); $callable = [$a, 'privateMethod']; $a->test($callable); $b->test($callable);

preferences:
52.1 ms | 402 KiB | 5 Q