Flock
(PHP 3>= 3.0.7, PHP 4 >= 4.0.0) Flock--Lock file description
BOOL Flock (int fp, int operation [, int wouldblock])
PHP supports full locking of files when accessing files (which means that all access programs have to use the same locking method, or that it does not work).
Flock () runs above the open file pointer fp.
Operation is one of the following values:
Get a shared lock (readable), set to Lock_sh (PHP 4.0.1 below is set to 1);
Get a mutex (only self-writable), set to LOCK_EX (PHP 4.0.1 below is set to 2);
Release the lock (release the shared or mutex), set to Lock_un (PHP 4.0.1 below is set to 3);
If you do not want to flock () block when locked, add LOCK_NB (PHP 4.0.1 below is set to 4).
Flock () allows you to use simple read/write modes (including numerous Unix derived systems and Windows systems) on every platform. If you want to lock a block, you can set the third argument to TRUE (ewouldblock errno condition)
Flock () returns TRUE for success; returns FALSE for failure (e.g. when a lock could not be acquired).
Note: Because flock () requires a file pointer, you can have the use of a special lock file to the protect access to a file, the intend to the truncate by Opening it in write mode (with a "w" or "w+" argument to Web site Building Server script Class \phpphp user manual Fancyfunction.fopen.html>fopen ()).
Warning
Flock () will not work in NFS and other network file systems. Please refer to your operating system files for more information.
Some operating systems flock () require execution at a certain level of execution. When using the multithreaded system API like ISAPI, you can not rely on flock () to protect files, whereas other PHP scripts are running in parallel threads in the same instance of the server.
http://www.bkjia.com/PHPjc/532341.html www.bkjia.com true http://www.bkjia.com/PHPjc/532341.html techarticle Flock (php 3>= 3.0.7, PHP 4 >= 4.0.0) Flock--Lock file description bool Flock (int fp, int operation [, int wouldblock]) PHP Branch Lock the file when accessing the file (which means ...