新创建的项目,在controller里面,echo数据报错,是什么问题 [ 新手入门 ]
代码
<?php
namespace frontend\controllers;
class PostController extends BaseController
{
public function actionIndex()
{
echo 123;
}
}
输出
123
An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /Users/gengshaojing/www/basic/frontend/controllers/PostController.php on line 10. in /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response->send()
#2 /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /Users/gengshaojing/www/basic/frontend/controllers/PostController.php on line 10. in /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /Users/gengshaojing/www/basic/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Response->send()
#2 /Users/gengshaojing/www/basic/frontend/web/index.php(17): yii\base\Application->run()
#3 {main}
共 3 条回复
gengshaojing
注册时间:2017-09-05
最后登录:2018-03-07
在线时长:0小时37分
最后登录:2018-03-07
在线时长:0小时37分
- 粉丝0
- 金钱20
- 威望0
- 积分20