是否可以将一个控制器的方法调用到Zend Framework中的另一个控制器或类中


Is it possible to call a method of a controller into another controller or class in Zend Framework?

我有一个控制器:

class XYZController extends ... 
{
   // Code here
   public abcAction()
   {
       // some code here
   }
   // end abcAction 
} 
// end class

是否可以创建该控制器的实例,以便能够调用该方法abcAction

我试过了,但它根本不起作用——它是一流的。我想在其他类中使用abcAction方法进行一些操作。

您必须包含XYZController 类所在的文件

include("yourpathtofile/XYZController.php");
$obj=new XYZController();
$obj->abcAction();