我们一直依赖这一段时间和最近更改的服务器。基本上,在一个php文件的结尾,我们关闭连接并做一些繁重的工作,我们不希望浏览器挂断。根据我的经验,我们使用的这个方法关闭浏览器连接,用户不会遇到任何问题。在这台新服务器上,连接保持打开状态并导致浏览器挂起。PHP ob_end_flush()不关闭浏览器连接
我做了这个非常简单的测试文件与它玩:
<?php
ob_end_clean();
ob_start();
?>
<html>
<head>
<title></title>
</head>
<body>
testing...
</body>
</html>
<?
$size = ob_get_length();
header("Content-Length: $size");
header('Connection: close');
ob_end_flush();
//anything below this should NOT hang up the browser
sleep(30); //but it does :-(
?>
我无法复制。请发布'phpinfo()'。 –