Home  >  Article  >  Backend Development  >  clearstatcache() function in PHP

clearstatcache() function in PHP

WBOY
WBOYforward
2023-09-07 09:33:03896browse

clearstatcache() function in PHP

clearstatcache() function is used to clear the file status cache.

PHP caches the information returned by the following functions −

  • stat()
  • lstat()
  • file_exists()
  • is_writable()
  • is_readable()
  • is_executable()
  • is_file()
  • is_dir()
  • filegroup()
  • fileowner()
  • filesize()
  • filetype()
  • fileperms()

This is done to provide better performance.

Syntax

void clearstatecache()

Parameters

  • NA

Return value

clearstatcache() function does not return any value .

Example

The following is an example to check the file "tmp.txt" and clear the cache.

Online demonstration

<?php
   $file = fopen("tmp.txt", "a+");
   // Clear cache
   clearstatcache();
   echo "Cache cleared!";
?>

Output

Cache cleared!

The above is the detailed content of clearstatcache() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete