Function 从另一个控制器Zend调用indexController中的函数
需要从另一个控制器(不是IndexController)调用某些函数,例如:Function 从另一个控制器Zend调用indexController中的函数,function,zend-framework,controller,call,Function,Zend Framework,Controller,Call,需要从另一个控制器(不是IndexController)调用某些函数,例如: class IndexController extends Zend_Controller_Action { public function indexAction() { $someFunction = new CustomController(); $someFunction->someFunc(); } } 但这带来了一个错误: Fatal error: Class 'CustomCon
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$someFunction = new CustomController();
$someFunction->someFunc();
}
}
但这带来了一个错误:
Fatal error: Class 'CustomController' not found in C:\xampp\htdocs\demo.ru\application\controllers\IndexController.php on line 13
如果
YourController::memberFunction()
跨多个控制器执行所需的操作,请将该代码放入操作帮助程序或库类中
这样两个控制器都可以访问共享功能,而不必相互依赖
我建议您遵循DRY并将这些函数移到公共库位置
要与命名空间一起使用,请参见
希望这一定会对您有所帮助。@user2794741,很高兴能帮助您,。