<?php
class ReportsController extends CController
{
public function __call($name,$argument)
{
echo "test";
}
}
?>
Run Code Online (Sandbox Code Playgroud)
这是我的Yii控制器类,当调用index.php?r=reports/testURL时,它必须调用该__call方法,因为测试方法不存在,但它给出了错误The system is unable to find the requested action test错误.
missingAction在控制器中实现方法,
正如@xdazz所说,它检查方法是否存在,如果不存在则调用missingAction方法。
//This method is invoked when the controller cannot find the requested action.
public function missingAction($actionID)
{
// Your code here
}
Run Code Online (Sandbox Code Playgroud)