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  ww.ja  v a2  s .  c o  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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions