它在 WAMP 本地主机上工作正常并且每-6ren">
gpt4 book ai didi

php - ob_flush() 在本地主机上工作但不在 GoDaddy 上在线

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:47:06 26 4
gpt4 key购买 nike

我有以下 PHP 脚本:

<?php 
ob_end_flush();
ob_start();
for ($i=0; $i < 10; $i++) {
echo "Line ".$i."</br>";
ob_flush();
flush();
sleep(1);
}
ob_end_flush();
?>

它在 WAMP 本地主机上工作正常并且每秒打印新行,但在 GoDaddy 经济托管在线时,它不起作用。它显示了 10 秒后除了页面加载之外没有任何反应的输出。

有什么问题吗?

最佳答案

It will work fine....

if(!ob_get_level()) ob_start();
echo json_encode(array('valid'=>true,'msg'=>'Flush occured.'));
$size = ob_get_length();
header("Content-Type: application/json");
// Set the content length of the response.
header("Content-Length: {$size}");
//Close the connection if you want to.
header("Connection: close");
// Flush all output.
ob_end_flush();
ob_flush();
flush();
// Close current session (if it exists).
if(session_id()) session_write_close();

关于php - ob_flush() 在本地主机上工作但不在 GoDaddy 上在线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41772740/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com