当我使用 xampp 进行 运行 项目时,我没有出现错误,但是在线出现这些错误
I have no error when I run project with xampp, but have these error online
我是 Yii2 的初学者,当我 运行 我的网站 Xampp 我没有任何错误,但在我将它上传到 linux 服务器后我得到了这个错误:
Non-static method frontend\controllers\SiteController::actionCategories() should not be called statically, assuming $this from incompatible context
这是什么原因造成的?
<?php
$category_post = \frontend\controllers\SiteController::actionCategories($row['id']);
echo ListView::widget([
'dataProvider' => $category_post,
'itemView' => 'news_title',
'summary' => '',
'pager' => [
'options' => ['class' => 'row pagination '],
]
]);
?>
只需使用
Yii::$app->controller->actionCategories($row['id']);
而不是
\frontend\controllers\SiteController::actionCategories($row['id']);
我是 Yii2 的初学者,当我 运行 我的网站 Xampp 我没有任何错误,但在我将它上传到 linux 服务器后我得到了这个错误:
Non-static method frontend\controllers\SiteController::actionCategories() should not be called statically, assuming $this from incompatible context
这是什么原因造成的?
<?php
$category_post = \frontend\controllers\SiteController::actionCategories($row['id']);
echo ListView::widget([
'dataProvider' => $category_post,
'itemView' => 'news_title',
'summary' => '',
'pager' => [
'options' => ['class' => 'row pagination '],
]
]);
?>
只需使用
Yii::$app->controller->actionCategories($row['id']);
而不是
\frontend\controllers\SiteController::actionCategories($row['id']);