Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php-不显示ob_start()的输出;_Php_Apache_Fpm_Ob Start - Fatal编程技术网

php-不显示ob_start()的输出;

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

在收到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']);
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()之后;它工作得非常好