http://net.tutsplus.com/tutorials/php/reflection-in-php/
// Nettuts.php
class Nettuts {
function publishNextArticle($editor) {
$editor->setNextArticle('135523');
$editor->publish(); // first call to publish()
$reflector = new ReflectionClass($editor);
$publishMethod = $reflector->getMethod('publish');
$publishMethod->invoke($editor); // second call to publish()
}
}
我无法理解这两个电话之间有什么区别
$publishMethod->invoke($editor);
和
$editor->publish(); // first call to publish()
我的意思是如果我们已经是$editor
那么为什么要通过反射类调用方法