The following code is available: {code ...} according to the Code, it seems that every one second, when json data is output and nginx is used as the web server, the above Code is displayed, and php is output once after 10 seconds of running the program. output_buffering4096 in ini was later posted on the internet... the following code is available:
For ($ I = 1; $ I <= 10; $ I ++) {echo json_encode (array ('error' => 0, 'msg '=>' This is the test output --'. $ I); ob_flush (); flush (); sleep (1 );}
According to the Code, it seems that the json data is output every second.
When nginx is used as the web server, the above Code will be output once after 10 s of running the program.
Output_buffering = 4096 in php. ini
Later, I tried to use ob_end_clean (); ob_implicit_flush (true); these functions, but they still didn't work.
Reply content:
The following code is available:
For ($ I = 1; $ I <= 10; $ I ++) {echo json_encode (array ('error' => 0, 'msg '=>' This is the test output --'. $ I); ob_flush (); flush (); sleep (1 );}
According to the Code, it seems that the json data is output every second.
When nginx is used as the web server, the above Code will be output once after 10 s of running the program.
Output_buffering = 4096 in php. ini
Later, I tried to use ob_end_clean (); ob_implicit_flush (true); these functions, but they still didn't work.
flush();ob_flush();
WAMP:
For ($ I = 1; $ I <= 10; $ I ++) {echo str_pad ('', 4096); echo json_encode (array ('error' => 0, 'msg '=>' This is the test output --'. $ I); ob_flush (); flush (); sleep (1 );}
I tried it. This is acceptable.
Http://segmentfault.com/q/1010000000447596
Under Ngnix:
Disable zlib. output_compression = Off in php. ini.
Disable gzip off under nginx. conf
Modify the code to echo str_pad ('', 64000 );
function test(){ header("Content-Encoding: none\r\n"); ini_set('zlib.output_compression', 'off'); ob_start(); for($i=0;$i<100;$i++){ echo str_repeat(" ",4096); echo $i."
"; ob_flush(); flush(); sleep(1); }}