ob_end_clean(): failed to delete buffer-ThinkPHP 5.1.23
来源:7-5 让Swoole完美支持TP5(下)
Superman007
2018-09-12
[thinkexceptionErrorException]
Uncaught thinkexceptionErrorException: ob_end_clean(): failed to delete buffer. No buffer to delete in /media/psf/Home/PhpstormPr
ojects/swoole.live.ipuxin.com/thinkphp/server/http_server.php:65
Stack trace:
#0 [internal function]: thinkError::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array)
#1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean()
#2 {main}
thrown
[2018-09-12 07:26:26 *17140.2] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught thinkexceptionErrorException: ob_end_c
lean(): failed to delete buffer. No buffer to delete in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_ser
ver.php:65
Stack trace:
#0 [internal function]: thinkError::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array)
#1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean()
#2 {main}
thrown in /media/psf/Home/Ph
老师,我的是ThinkPHP 5.1.23
写回答
3回答
-
夜明河
2020-04-19
遇到了同样的情况,控制器那边不能只echo,还必须return。
return ""; 也行。
只echo的话,就会报错,可能是和老师的版本有小差异的
012020-04-19 -
Superman007
提问者
2018-09-13
$http = new swoole_http_server("0.0.0.0", 8899); $http->set([ 'enable_static_handler' => true, 'document_root' => '/media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/public/static', 'worker_num' => 4, ]); $http->on('WorkerStart', function (swoole_server $server, $worker_id) { //定义应用目录 define('APP_PATH', __DIR__ . '/../../application/'); //加载基础文件 require __DIR__ . '/../base.php'; }); $http->on('request', function ($request, $response) use($http) { if (isset($request->server)) { foreach ($request->server as $key => $item) { $_SERVER[strtoupper($key)] = $item; } } if (isset($request->header)) { foreach ($request->header as $key => $item) { $_SERVER[strtoupper($key)] = $item; } } if (isset($request->get)) { foreach ($request->get as $key => $item) { $_GET[$key] = $item; } } if (isset($request->post)) { foreach ($request->post as $key => $item) { $_POST[$key] = $item; } } ob_start(); try { // 执行应用并响应 \think\Container::get('app', [APP_PATH])->run()->send(); } catch (\Exception $e) { echo "TP5 Error"; } // $action = request()->action(); // echo $action; $result = ob_get_contents(); ob_end_clean(); $response->end("This get is: " . json_encode($result)); }); $http->start();
[parallels@swoole ~]$ php /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php This is form controller! dfasdfPHP Fatal error: Uncaught think\exception\ErrorException: ob_end_clean(): failed to delete buffer. No bu ffer to delete in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php:65 Stack trace: #0 [internal function]: think\Error::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array) #1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean() #2 {main} thrown in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php on line 65 [think\exception\ErrorException] Uncaught think\exception\ErrorException: ob_end_clean(): failed to delete buffer. No buffer to delete in /media/psf/Home/PhpstormPr ojects/swoole.live.ipuxin.com/thinkphp/server/http_server.php:65 Stack trace: #0 [internal function]: think\Error::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array) #1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean() #2 {main} thrown [2018-09-13 06:17:15 *11781.2] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught think\exception\ErrorException: ob_end_c lean(): failed to delete buffer. No buffer to delete in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_ser ver.php:65 Stack trace: #0 [internal function]: think\Error::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array) #1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean() #2 {main} thrown in /media/psf/Home/Ph [2018-09-13 06:17:15 $11774.0] WARNING swManager_check_exit_status: worker#2 abnormal exit, status=255, signal=0
老师,可能是thinkphp版本问题,我的是最新的。
00 -
singwa
2018-09-12
同学你好 ob_start开启了吗?
022019-01-31
相似问题