PHP Tutorial - PHP clearstatcache() Function






Definition

The clearstatcache() function clears the file status cache.

Syntax

PHP clearstatcache() Function has the following syntax.

clearstatcache()

Note

Functions that are caching:

  • stat()
  • lstat()
  • file_exists()
  • is_writable()
  • is_readable()
  • is_executable()
  • is_file()
  • is_dir()
  • is_link()
  • filectime()
  • fileatime()
  • filemtime()
  • fileinode()
  • filegroup()
  • fileowner()
  • filesize()
  • filetype()
  • fileperms()




Example

Clears the file status cache


<?php/*from   w  w w . j  av a 2 s  .co m*/
echo filesize("test.txt");
echo "\n";

$file = fopen("test.txt", "a+");

ftruncate($file,200);
fclose($file);

clearstatcache();
echo filesize("test.txt");
?>

The code above generates the following result.