MemoryRefresh!

File cache and stats



Questions Answers 0%

Pages   0 from 51
Questions   0 from 84

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
Questions

Related pages

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


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




Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


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



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com