Advertisement
markuszeller

ReflectionMethodInvoke

Aug 16th, 2022 (edited)
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. // https://stackoverflow.com/questions/73377269/using-reflection-class-in-php-also-unable-to-access-private-property
  2.  
  3. class Forbidden
  4. {
  5.     private function doSomething(): void
  6.     {
  7.         echo "Forbidden";
  8.     }
  9. }
  10.  
  11. $class = new ReflectionClass(Forbidden::class);
  12. $func  = $class->getMethod('doSomething');
  13. $func->invoke(new Forbidden());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement