PHP clearstatcache example, clearstatcache php, clearstatcache in php


 

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.

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

 

Ads