It should be noted that a call to any of those functions will cache all of the file's information, not just the information that is returned.
Obviously it is clear that the following requires you to clear the cache.
<?php
$size1 = filesize($filename);
unlink($filename);
$size2 = filesize($filename);
// $size2 still equals $size1, unless you cleared the stat cache in between.
?>
<?php
$access = fileatime($filename);
unlink($filename);
$size = filesize($filename);
// $size will be the filesize before it was unlinked, because the filesize was cached when fileatime was called, even though the two functions wouldn't appear to have anything to do with either other.
?>
Confirmed on a windows system.
clearstatcache
(PHP 4, PHP 5)
clearstatcache — Vymaže cache stavu souborů
Popis
void clearstatcache ( void )
Volání systémových funkcí stat či
lstat má poměrně velkou režii. Tudíž se výsledek
posledního volání všech stavových funkcí (viz seznam níže) ukládá pro použití
při dalším takovém volání používajícím stejný název souboru. Pokud chcete
vynutit novou kontrolu stavu, např. pokud je soubor kontrolován mnohokrát
a může se změnit nebo zmizet, použijte tuto funkci k uvolnění výsledků
posledního volání z paměti.
Tato hodnota se cachuje pouze po dobu běhu skriptu.
Ovlivněné funkce: stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), a fileperms().
clearstatcache
24-Jan-2008 03:35
