Php __尝试调用yii控制器中不存在的函数时,调用方法未执行?

Php __尝试调用yii控制器中不存在的函数时,调用方法未执行?,php,yii,Php,Yii,这是我的Yii控制器类,当调用index.php?r=reports/testURL时,它必须调用\u call方法,因为test方法不存在,但它给出了错误系统无法找到请求的操作测试错误。这取决于框架的实现 例如,如果框架实现如下代码: <?php class ReportsController extends CController { public function __call($name,$argument) { echo "test"; }

这是我的Yii控制器类,当调用
index.php?r=reports/test
URL时,它必须调用
\u call
方法,因为test方法不存在,但它给出了错误
系统无法找到请求的操作测试
错误。

这取决于框架的实现

例如,如果框架实现如下代码:

<?php
class ReportsController extends CController
{
    public function __call($name,$argument)
    {
        echo "test";
    }

}
?>

在控制器中执行
missingAction
方法

正如@xdazz所说,它检查方法是否存在,如果不存在,则调用
missingAction
方法

If (!method_exists($controller, $action)) {
  throw new Exception("The system is unable to find the requested action $action");
}
//This method is invoked when the controller cannot find the requested action.

public function missingAction($actionID)
{
    // Your code here
}