Home Tutorial Php Phpfiles PHP clearstatcache example, clearstatcache php, clearstatcache in php

 
 

Share on Google+Share on Google+
PHP clearstatcache example, clearstatcache php, clearstatcache in php
Posted on: September 21, 2009 at 12:00 AM
Advertisement
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

<?php

$a=fopen("c:/rose1/ram.txt","w");

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";

fwrite($a,$p);

clearstatcache();

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

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

?>

output

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

 

Advertisement

Related Tags for PHP clearstatcache example, clearstatcache php, clearstatcache in php:


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.

Posted on: September 21, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com