Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://stackoverflow.com/questions/73377269/using-reflection-class-in-php-also-unable-to-access-private-property
- class Forbidden
- {
- private function doSomething(): void
- {
- echo "Forbidden";
- }
- }
- $class = new ReflectionClass(Forbidden::class);
- $func = $class->getMethod('doSomething');
- $func->invoke(new Forbidden());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement