integer filesize(string filename)
The filesize function returns the size of the given file in bytes.
<?
print(filesize("data.txt"));
?>
string filetype(string filename)
The filetype function returns the type of the given file as a descriptive string. Possible
values are block, char, dir, fifo, file, link, and unknown. This function is an
interface to C's stat function, whose man page may be helpful in understanding the
different file types.
<?
print(filetype("data.txt"));
?>
boolean flock(integer file_handle, integer mode)
Use the flock function to temporarily restrict access to a file. PHP uses its own system
for locking, which works across multiple platforms. However, all processes must be
using the same locking system, so the file will be locked for PHP scripts, but likely not
locked for other processes.
The file_handle argument must be an integer returned by fopen. The mode argument
determines whether you obtain a lock that allows others to read the file (1), you obtain a
lock that doesn't allow others to read the file (2), or you release a lock (3). When
obtaining a lock, the process may block. That is, if the file is already locked, it will wait
until it gets the lock to continue execution. If you prefer, you may turn off blocking using
modes 5 and 6. Table 8.5 lists the modes in a table.
Table 8.5. flock Modes
Mode Operations Allowed
1 Allow reads
2 Disallow reads
3 Release lock
5 Allow reads, do not block