I have a script on a shared host that uses suPHP. I need unbuffered output (so I can flush before starting a lengthy subroutine) but can't find anyway to get it working, so my flush calls basically just get ignored. I have tried tweaking the .htaccess (which results in a 500 internal error), I've tried modifying a php.ini at the account leve开发者_JS百科l and in the folder level for the specific script (both of which seem to be completely ignored, I can't for example disable the php engine with engine = Off or suphp_engine = Off).
How can I get buffering disabled (might have to ask my hosting provider, but what do I ask them to change specifically)? Is it even possible with suPHP?
After talking with my hosting support some more I finally got php.ini to get recognized, but dissabling or altering the buffer size there has no effect. It's fairly poorly documented (one comment on the php official docs as far as I can tell) but it seems suPHP buffers ALL output AFTER the internal php buffers. So flush is working... but all the output is getting buffered again by suPHP and there's no way around it. So if you're using suPHP you're stuck behind a second buffer that can't be turned off, and the end result is flushes will have no effect. You can use the other buffer commands, such as buffering so you can send headers further through a script, to control flow, but the total output behind suPHP goes through a buffer before going out.
What happens when you execute flush()
? Do you get an error, or simply no output? If caching is occurring at the webserver level you may need to fill its buffer for flush to take effect. try sending a lot of whitespace before the flush and see if it's more effective.
精彩评论