Share on Google+Share on Google+

PHP clearstatcache example, clearstatcache php, clearstatcache in php

In this section We will show you the example of PHP clearstatcache() function. This PHP clearstatcache() function is used to clear the cache associated with a file.

The example & code of clearstatcache()  in the PHP programming language.

If you are performing the multiple operations on the file using following functions stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), and fileperms()., then the PHP will store cache in the memory. You need to clear the cache if you are using the these functions in the same php program multiple times. The following example explains how the clearstatcache() function can be used.

Syntax clearstatcache() Function in PHP

clearstatcache ([ bool $clear_realpath_cache = false [, string $filename ]] )

It clears or removes the file status value from the cache stored in the memory. 

code for clearstatcache() in PHP



echo "<br>file-size before clearstatcache() function ..<br>";

echo filesize("c:/rose1/ram.txt");

$p="welcome to roseindia\nwelcome to roseindia\nwelcome to roseindia\nwelcome to roseindia\nwelcome to roseindia\nwelcome to roseindia\n";



echo "<br>file-size after clearstatcache() function ..<br>";

echo filesize("c:/rose1/ram.txt");



file-size before clearstatcache() function ..
file-size after clearstatcache() function ..



Posted on: September 21, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.