Created
June 13, 2014 15:01
-
-
Save igor822/3489bc1e355ca7c33681 to your computer and use it in GitHub Desktop.
Execute a private method in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
private function teste() { | |
return 'teste ab'; | |
} | |
} | |
$class = new A(); | |
//$class->teste(); | |
$reflactor = new ReflectionClass('A'); | |
$reflactor_method = $reflactor->getMethod('teste'); | |
$reflactor_method->setAccessible(true); | |
echo $reflactor_method->invoke($class, NULL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment