Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

clearstatcache

Description

The clearstatcache of Filesystem for PHP clears file status cache.

Syntax

clearstatcache(bool $clear_realpath_cache = false, string $filename = ""): void

Parameters

clear_realpath_cache

Whether to clear the realpath cache or not.

filename

Clear the realpath and the stat cache for a specific filename only; only used if clear_realpath_cache is TRUE.

Return

No value is returned.

Examples

1

<?

function myfunction($filename)
{
    $stat = stat($filename);
    $uid = $stat["uid"];
    $posix_getpwuid = posix_getpwuid($uid);

    return $posix_getpwuid["name"];
}

$format = "%s: %s\n";
$filename = "clearstatcache.txt";

printf($format, date("r"), myfunction($filename));

chown($filename, "myowner");
printf($format, date("r"), myfunction($filename));

clearstatcache();
printf($format, date("r"), myfunction($filename));

?>
Tue, 23 Apr 2024 13:18:43 +0000: root
Tue, 23 Apr 2024 13:18:43 +0000: root
Tue, 23 Apr 2024 13:18:43 +0000: myowner
HomeMenu