I wanted to implement Comet in PHP and came across this page:
http://www.zeitoun.net/articles/comet_and_php/start
The second method explained in the article works fine for me. In the backend php file, the loop seems to be infinite:
// 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);
  }
When the client leaves the page, how to tell the server to stop processing the loop? Otherwise I fear that the loop is going to go on and on on the server until something is modified.
You need to check the connection_status function.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论