4
ignore_user_abort가 작동하는지 확인하기 위해 로그 프린터를 사용했습니다. 그러나 반향은 작동하기를 원하지 않습니다. 에코는 루프가 완료 될 때만 작동합니까?do while 루프 또는 ignore_user_abort (1)에서 echo가 작동하지 않는 이유는 무엇입니까?
<?php
ignore_user_abort(1); // run script in background
set_time_limit(0); // run script forever
$interval=2; // do every 2 sec...
$i=0;
$lastRunLog = 'lastrun.log';
do{
// add the script that has to be ran every 2 sec here
// ...
echo 'Test: '.$i;
file_put_contents($lastRunLog, time());
sleep($interval); // wait 2 sec
$i=$i+1;
}while(true);
?>
예, PHP가 완료되고 서버에서 브라우저로 전송 된 경우에만 에코가 표시됩니다 –