12
Is there any way to make PHP wait until a function returns before continuing?
This is my code:
<?php
set_time_limit(0);
function waitforchange($nof) {
$lfilemod=filemtime($nof);
while(filemtime($nof) == $lfilemod) {
clearstatcache();
usleep(10000);
}
}
waitforchange('./blahblah.txt')
sleep(5);
echo 'done';
?>
It is supposed to wait until blahblah.txt changes, wait another five seconds after that, then print out "done", however, it prints out "done" after five seconds, regardless whether the file actually changed.