Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/function/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 从另一个控制器Zend调用indexController中的函数_Function_Zend Framework_Controller_Call - Fatal编程技术网

Function 从另一个控制器Zend调用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

需要从另一个控制器(不是IndexController)调用某些函数,例如:

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,很高兴能帮助您,。