3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function myPrivate() { return true; } } class Bar extends Foo {} $obj = new Bar; $reflMethod = new \ReflectionMethod($obj, 'myPrivate'); $reflMethod->setAccessible(true); $return = $reflMethod->invoke($obj); var_dump($return);

preferences:
29.39 ms | 405 KiB | 5 Q