When actively refreshing, the program must constantly judge whether there is a new statement, and if not, repeat it.
Here I introduce a method similar to C language programming effect
//A time mark, because generally PHP scripts There is a time limit for execution
$delaytime=0;
//Loop
while(1)
{
//Determine whether there are new statements. My $filename here stores the total number of statements. , $last is the last message displayed
$message = file($filename);
$number = $message[0];
//Delay for 1 second
sleep(1 );
//The time mark increases
$delaytime++;
//If the time mark reaches the allowed script running time, exit the loop
if($delaytime > 25) break;
/ /If there is a new statement, exit the loop
if($number > $last) break;
}
//Process updates
... ...
This will not happen The page keeps refreshing, which is very annoying! ! !