Syntax of clearstatcache
void clearstatcache([bool clear_realpath_cache[, string file ]])
Clears the file status functions cache. The next call to any of the file status functions will retrieve the information from the disk. The clear_realpath_cache parameter allows for clearing the realpath cache. The file parameter allows for the clearing of the realpath and stat caches for a specific filename only, and it can only be used if clear_realpath_cache is true.
Example of clearstatcache
<?php
$file = 'output_log.txt';
function get_owner($file)
{
$stat = stat($file);
$user = posix_getpwuid($stat['uid']);
return $user['name'];
}
$format = "UID @ %s: %s\n";
printf($format, date('r'), get_owner($file));
chown($file, 'ross');
printf($format, date('r'), get_owner($file));
clearstatcache();
printf($format, date('r'), get_owner($file));
?>
UID @ Sun, 12 Oct 2008 20:48:28 +0100: root UID @ Sun, 12 Oct 2008 20:48:28 +0100: root UID @ Sun, 12 Oct 2008 20:48:28 +0100: ross