Php 如何阻止这种AJAX?

Php 如何阻止这种AJAX?,php,ajax,comet,infinite-loop,Php,Ajax,Comet,Infinite Loop,我想在PHP中实现Comet,遇到了以下页面: 文章中解释的第二种方法对我来说很好。在后端php文件中,循环似乎是无限的: // infinite loop until the data file is not modified $lastmodif = isset($_GET['timestamp']) ? $_GET['timestamp'] : 0; $currentmodif = filemtime($filename); while ($currentmodif &

我想在PHP中实现Comet,遇到了以下页面:

文章中解释的第二种方法对我来说很好。在后端php文件中,循环似乎是无限的:

// infinite loop until the data file is not modified
  $lastmodif    = isset($_GET['timestamp']) ? $_GET['timestamp'] : 0;
  $currentmodif = filemtime($filename);
  while ($currentmodif <= $lastmodif) // check if the data file has been modified
  {
    usleep(10000); // sleep 10ms to unload the CPU
    clearstatcache();
    $currentmodif = filemtime($filename);
  }
//无限循环,直到数据文件未修改
$lastmodif=isset($\u GET['timestamp'])$_获取['timestamp']:0;
$currentmodif=filemtime($filename);

虽然($currentmodif您需要检查函数。

您需要检查函数。

PHP文档中说:
默认行为是当远程客户端断开连接时,脚本将被中止。
这是否意味着当启动AJAX请求的客户端断开连接时,循环将被中断需要做的是测试并找出答案。谢谢。我会玩这个并找出答案。修复完成后会更新。PHP文档说:
默认行为是当远程客户端断开连接时,脚本会被中止。
这是否意味着当启动AJAX请求的客户端断开连接时,循环将被终止被破坏了?最好的办法就是测试并找出答案。谢谢。我会玩这个并找出答案。修复完成后会更新。