mevsme
mevsme

Reputation: 559

php filemtime in a loop at CLI on Windows doesn't get updates

I have a loop

while (true) {
    $time = filemtime($file);
    echo date("Y m d H i s", $time) . PHP_EOL;
    sleep(3);
}

Then I change the file, and PHP doesn't see modification unless I restart the loop. After restart, PHP shows new mod date. How can I overcome this?

Upvotes: 1

Views: 112

Answers (1)

mevsme
mevsme

Reputation: 559

Use clearstatcache() to clear chached vale for that file.

Upvotes: 1

Related Questions