How to correctly show output at every echo on all browsers?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 15:08:07

Excerpt from the flush documentation:

flush() may not be able to override the buffering scheme of your web server and it has no effect on any client-side buffering in the browser. [...]

Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.

Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.

Chances are high that you changed to a different web server (or web server configuration), which buffers the output of the whole script before outputting it.

The setting you're looking for is in your PHP.ini and it's called output_buffering:

; output_buffering
;   Default Value: Off
;   Development Value: 4096
;   Production Value: 4096

Set it to off manually and restart your webserver to make flush() actually flush something when you want it, not after 4kb of data :)

Note that ini_set doesn't always necessarily has to work for this. If you want full control, disable it in php.ini itself, or as a .htacces php_value flag

Browsers decide for themselves when to output content. So if you don't meet that threshold, they'll just wait until it is met and only then show more content to the user.

Try to add to .htaccess

    php_value output_buffering Off
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!