Pedro Gabriel
Pedro Gabriel

Reputation: 505

PHP filetime is not getting updated

I was trying to get last file modified time as a LIVE thing but it is not getting updated...

Running this at PHP cli:

<?php
$filename = 'include.php';

while(1){
    sleep(1);
    echo date('H:i:s',filemtime($filename))."\n";
}

?>

When I update the file it does not get the last updated time..

Someone know why?

Thanks!

Upvotes: 0

Views: 404

Answers (1)

Federkun
Federkun

Reputation: 36964

If you see the doc, it say

Note: The results of this function are cached. See clearstatcache() for more details.

So, you have to call clearstatcache() at the end of the while.

Upvotes: 1

Related Questions