<?php
class ReportsController extends CController
{
public function __call($name,$argument)
{
echo "test";
}
}
?>
这是我的 Yii Controller 类,当调用 index.php?r=reports/test
URL 时,它必须调用 __call
方法,因为测试方法不存在但它给出错误 The system is unable to find the requested action test
错误。
最佳答案
在你的 Controller 中实现missingAction
方法,
如@xdazz 所述,它检查方法是否存在,如果不存在,则调用 missingAction
方法。
//This method is invoked when the controller cannot find the requested action.
public function missingAction($actionID)
{
// Your code here
}
关于php - __call 方法在尝试调用 yii Controller 中不存在的函数时未执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12852724/