当使用 EasyTabs 扩展中的 Controller 操作调用 View 文件时,我收到类似 fatal error :在第 661 行 ..\controllers\ServiceRequestController.php 中不在对象上下文中时使用 $this 的错误
。
我正在 View 文件中像这样调用 Controller 操作
ServiceRequestController::actionTest();
和 Controller
public static function actionTest()
{
$this->redirect('test');
}
如何消除这个错误?当我谷歌搜索时,我发现 $this 不能在静态方法中使用。
。所以我尝试使用
$model = new ServiceRequest();
$model->Test();
在我的 View 文件中。但它显示错误为 ServiceRequest 及其行为没有名为“actionTest”的方法或闭包。
谁能帮我修复错误?提前致谢
我尝试使用此链接进行修复。但我想我错了。 PHP Fatal error: Using $this when not in object context
最佳答案
关于php - 在 Yii 中不在对象上下文中时使用 $this,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16330985/