Skip to content

Instantly share code, notes, and snippets.

@hnw
Created May 16, 2011 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnw/973977 to your computer and use it in GitHub Desktop.
Save hnw/973977 to your computer and use it in GitHub Desktop.
<?php
/* requires PHP 5.3.2 */
class Foo
{
private function doSomethingPrivate($arg)
{
return 'foo'.$arg;
}
}
$method = new ReflectionMethod('Foo', 'doSomethingPrivate');
$method->setAccessible(true);
var_dump($method->invoke(new Foo(), 'bar')); // string(6) "foobar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment