MemoryRefresh!

Streams / File cache and stats   File cache and stats



Questions Answers 0%

Pages   0 from 91
Questions   0 from 142

Reset


clearstatcache() If you call file_exists() on a file that doesn't exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file. However unlink() clears the cache automatically.
<?php // Clears the information that PHP caches about a file $fw = fopen ("test.txt", "w"); fwrite ($fw, "test"); fclose ($fw); echo (int) file_exists("test.txt"); // Outputs: 1 unlink ("c:test.txt"); echo (int) file_exists ("test.txt"); // Outputs: 1 clearstatcache(); echo (int) file_exists ("test.txt"); // Outputs: 0 stat()
<?php // Gives information about a file $stat = stat("example.txt"); echo 'Access time: ' . $stat['atime']; // file access time, // this is the same as calling fileatime() echo 'Modification time: ' . $stat['mtime']; // Print file modification time, // this is the same as calling filemtime() echo 'Device number: ' . $stat['dev']; // Print the device number fstat() Gets information about a file using an open file pointer. This function is similar to the stat() function except that it operates on an open file pointer instead of a filename.
<?php $fp = fopen("/etc/passwd", "r"); // open a file $fstat = fstat($fp); // gather statistics

Related Pages

File open
Read file
Read csv
File contents
File cache and stats
File lock
File parse
Context
Network


0% 100%
 
 
0 pages 91 pages
1) Get stats for a file







clearstatcache() If you call file_exists() on a file that doesn't exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file. However unlink() clears the cache automatically.
<?php // Clears the information that PHP caches about a file $fw = fopen ("test.txt", "w"); fwrite ($fw, "test"); fclose ($fw); echo (int) file_exists("test.txt"); // Outputs: 1 unlink ("c:test.txt"); echo (int) file_exists ("test.txt"); // Outputs: 1 clearstatcache(); echo (int) file_exists ("test.txt"); // Outputs: 0 stat()
<?php // Gives information about a file $stat = stat("example.txt"); echo 'Access time: ' . $stat['atime']; // file access time, // this is the same as calling fileatime() echo 'Modification time: ' . $stat['mtime']; // Print file modification time, // this is the same as calling filemtime() echo 'Device number: ' . $stat['dev']; // Print the device number fstat() Gets information about a file using an open file pointer. This function is similar to the stat() function except that it operates on an open file pointer instead of a filename.
<?php $fp = fopen("/etc/passwd", "r"); // open a file $fstat = fstat($fp); // gather statistics

References









Programming

Php
   
Regex
   
MySQL
   
Css
   
jQuery
   
Git
   


References