[英]PHP flush() / ob_flush() not working only with Android browser
I have found similar questions but none as specific as this one. 我发现了类似的问题,但没有一个比这个问题更具体。 The following code is a simplified version that reproduces the problem.
下面的代码是重现该问题的简化版本。
<?php
function addProgressText($texto)
{
echo '<script type="text/javascript">';
echo 'document.getElementById("mensajesEnProgreso").innerHTML += "'.$texto.'";';
echo '</script>';
flush();
ob_flush();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>TEST - Flush for Android</title>
</head>
<body>
<div id="divEnProgreso">
<p id="mensajesEnProgreso"></p>
</div>
<?php
addProgressText("Init...");
sleep(5);
addProgressText("OK<br>Step 1... ");
sleep(5);
addProgressText("OK<br>Step 2... ");
sleep(5);
addProgressText("OK<br>Step 3... ");
sleep(5);
addProgressText("OK<br>FINISHED");
?>
</body>
</html>
The code works as expected (displays the steps one by one) on Chrome, Firefox and IE, but when I open it from an Android browser, the flushes don't work and everything is displayed at once upon completion. 该代码可在Chrome,Firefox和IE上按预期方式工作(逐个显示步骤),但是当我从Android浏览器中打开该代码时,刷新将不起作用,并且所有内容在完成后立即显示。
Any hints on the source of the problem? 关于问题根源的任何提示吗? Thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.