在php中使用反射类和普通方法调用方法有什么区别

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()
   }

}

I am not able to understand what is difference between these two calls

$publishMethod->invoke($editor);

and

$editor->publish(); // first call to publish()

I mean if we already was $editor then why would be invoke method through reflection class

There is two approaches: call method directly and call method using reflection.

Sometimes you need to convert function name as "string" to a real callable function.

For example, with some validation framework, you need to configure some rules. e.g.

addRule("notEmpty") 

"notEmpty" will be a method name(as string), and you can invoke the real method by Reflection.