我收到一个错误,例如Fatal error: Using $this when not in object context in ..\controllers\ServiceRequestController.php on line 661
使用 EasyTabs 扩展中的控制器操作调用视图文件时。我在视图文件和控制器
中调用这样的控制器操作
ServiceRequestController::actionTest();
public static function actionTest()
{
$this->redirect('test');
}
我怎样才能摆脱这个错误?当我用谷歌搜索时,我发现$this cannot be used in a static method.
. 所以我尝试
$model = new ServiceRequest();
$model->Test();
在我的视图文件中使用。但它显示错误,因为ServiceRequest and its behaviors do not have a method or closure named "actionTest".
有人可以帮我修复错误吗?在此先感谢我尝试使用此链接进行修复。但我认为我错了。PHP 致命错误:不在对象上下文中使用 $this