suPHP 使用无缓冲输出?
我在共享主机上有一个使用 suPHP 的脚本。我需要无缓冲的输出(这样我可以在开始冗长的子例程之前刷新),但无论如何找不到让它工作,所以我的刷新调用基本上被忽略。我尝试过调整 .htaccess (这会导致 500 内部错误),我尝试在帐户级别和特定脚本的文件夹级别修改 php.ini (这两者似乎都被完全忽略,我例如,不能使用 engine = Off 或 suphp_engine = Off 禁用 php 引擎。
我怎样才能禁用缓冲(可能需要询问我的托管提供商,但我应该要求他们具体更改什么)? suPHP 也可以实现吗?
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 level 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在与我的托管支持人员进行了更多交谈后,我终于得到了 php.ini 的识别,但是禁用或更改缓冲区大小没有任何效果。它的记录相当少(据我所知,对 php 官方文档的一条评论),但似乎 suPHP 缓冲了内部 php 缓冲区之后的所有输出。所以刷新正在工作...但是所有输出都被 suPHP 再次缓冲,并且没有办法解决它。因此,如果您使用 suPHP,您将陷入无法关闭的第二个缓冲区后面,最终结果是刷新将不起作用。您可以使用其他缓冲区命令(例如缓冲),以便您可以通过脚本进一步发送标头,以控制流程,但 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.
当你执行
flush()
时会发生什么?您是否收到错误或根本没有输出?如果缓存发生在网络服务器级别,您可能需要填充其缓冲区以使刷新生效。尝试在刷新之前发送大量空格,看看是否更有效。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.