PHP4用户手册:函数-flock_PHP教程

WBOY
Freigeben: 2016-07-13 17:22:22
Original
1141 Leute haben es durchsucht

flock
(PHP 3>= 3.0.7, PHP 4 >= 4.0.0)flock -- 锁定文件描述
bool flock (int fp, int operation [, int wouldblock])
PHP 支持在访问文件时完全的锁定文件(这意味着所有的访问程序不得不使用相同的锁定方式,或者它不工作)。
flock() 运行在打开的文件指针fp之上。
operation 是下列值之一:
获得一个共享锁(可读),设置为LOCK_SH (PHP 4.0.1以下设置为1);
获得一个互斥锁(只有自己可写),设置为LOCK_EX (PHP 4.0.1以下设置为2);
释放锁(释放共享锁或互斥锁),设置为LOCK_UN (PHP 4.0.1以下设置为3);
如果当锁定时你不想flock() 块,添加LOCK_NB (PHP 4.0.1以下设置为4)。
flock() 允许你在每一个平台上能被使用简单的读/写模式 (包括众多的 Unix 派生系统和 Windows系统). 如果你想锁住块,你可以设置第三个参数为 TRUE (EWOULDBLOCK errno condition)
flock() 返回 TRUE 为成功;返回 FALSE 为失败 (e.g. when a lock could not be acquired).
注意: 因为 flock() 需要一个文件指针,you may have to use a special lock file to protect access to a file that you intend to truncate by opening it in write mode (with a "w" or "w+" argument to 网站建设服务器脚本类\PHPPHP用户手册fancyfunction.fopen.html>fopen()).


警告
flock() 在NFS和其他的网络文件系统中将不工作。详细资料请查阅你的操作系统文件。
有些操作系统 flock() 的执行需要在一定的执行级别上。当使用多线程系统API象ISAPI,你不可以依赖flock()去保护文件,相反其他的 PHP 脚本正在同一的服务器的实例中平行线程中运行。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532341.htmlTechArticleflock (PHP 3>= 3.0.7, PHP 4 >= 4.0.0)flock -- 锁定文件描述 bool flock (int fp, int operation [, int wouldblock]) PHP 支持在访问文件时完全的锁定文件(这意味着所...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!