die() 是否执行 ob_end_flush() ?
我似乎无法在任何地方找到一个好的答案。如果我正在运行输出缓冲,并且 die()
被触发,是否也会启动 ob_end_flush()
?
I can't seem to find a good answer on this anywhere. If I am running output buffering, and a die()
is fired, does that kick off an ob_end_flush()
as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,确实如此。每当脚本正常结束时,缓冲区都会被清空。唯一不优雅的结局是分段错误或被杀死(信号 9 SIG_KILL)。
die()
对进程进行硬终止的唯一地方是,如果您在register_shutdown_function
内部调用它(但是在调用关闭函数之前缓冲区会被刷新) ,所以那里没有问题)。有关更多信息,请参阅连接处理...Yes it does. Any time the script ends gracefully, the buffers will be emptied. The only non-graceful endings are if it segmentation faults or if it's killed (signal 9 SIG_KILL). The only place that
die()
does a hard-kill of the process is if you call it inside of aregister_shutdown_function
(But the buffers are flushed before the shutdown function is called, so there's no issue there). See Connection Handling for some more information...是的。
则可以将输出设置为空
但是,如果您之前有代码,
。在某些情况下,我们不想在 die() 上输出 ob。
我在这里写下这篇文章是为了帮助任何想要做同样事情的人。
Yes.
However, you can make the output empty if you have
earlier in the code.
In some cases we did not want to output the ob on a die().
I write this here in case it could help anyone who wants to do the same.