An Error occurred while handling another error: exception 'yii\web\HeadersAlreadySentException' with message 'Headers already sent in /xxxxx/controllers/xxxController.php on line 245.' in /xxxxx/vendor/yiisoft/yii2/web/Response.php:366 Stack trace: #0 /xxxx/yii2/web/Response.php(339): yii\web\Response->sendHeaders() #1 /xxxx/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response->send() #2 /xxxx/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}
返回内容使用echo 返回,在echo 'xxxx';后加exit();
或者把echo改成return,之后就不会在报错