php-不显示ob_start()的输出;
在收到apache的200响应后,我试图在后台运行一个PHP脚本,但是,它不起作用,我在下面的代码中遇到了一个小问题,我不知道为什么php-不显示ob_start()的输出;,php,apache,fpm,ob-start,Php,Apache,Fpm,Ob Start,在收到apache的200响应后,我试图在后台运行一个PHP脚本,但是,它不起作用,我在下面的代码中遇到了一个小问题,我不知道为什么 <?php ignore_user_abort(true); set_time_limit(0); ob_start(); header('Content-Type: application/json'); // output the array to screen echo json_encode(['data' => 'foo']); heade
<?php
ignore_user_abort(true);
set_time_limit(0);
ob_start();
header('Content-Type: application/json');
// output the array to screen
echo json_encode(['data' => 'foo']);
header('Connection: close');
header('Content-Length: ' . ob_get_length());
ob_end_flush();
ob_flush();
flush();
// run the rest of the code in background
我发现了这个问题
我在服务器上启用了gzip,因此添加了标题:
header("Content-Encoding: none");
在ob_start()之后;它工作得非常好