我是Yii框架的新手。我刚开始学习Yii 2.0,但我出现了以下错误。
已经在controller/SiteController.php 中编写了以下代码
class SiteController extends Controller
{
// ...existing code...
public function actionSay($message = ’Hello’)
{
return $this->render(’say’, [’message’ => $message]);
}
}
并在views/ControllerID/ViewName.php 中编写了以下代码
<?php
use yii'helpers'Html;
?>
<?= Html::encode($message) ?>
所以当我在浏览器中运行此行时"http://localhost/web/index.php?r=site/say&message=你好+世界"正在获取以下错误
PHP Notice – yii'base'ErrorException
Use of undefined constant ’message’ - assumed '’message’'
1. in C:'xampp'htdocs'basic'controllers'SiteController.php at line 99
90919293949596979899100101 }
public function actionAbout()
{
return $this->render('about');
}
public function actionSay($message = ’Hello’)
{
return $this->render('say', [’message’ => $message]);
}
}
2. in C:'xampp'htdocs'basic'controllers'SiteController.php – yii'base'ErrorHandler::handleError(8, 'Use of undefined constant ’messa...', 'C:'xampp'htdocs'basic'controller...', 99, ...) at line 99
93949596979899100101 {
return $this->render('about');
}
public function actionSay($message = ’Hello’)
{
return $this->render('say', [’message’ => $message]);
}
}
有谁能帮我解决这个错误吗。
REPLACE:返回$this->render('say',['message'=>$message]);WITH:return$this->render('say',['message'=>$message]);