search
Homephp教程php手册PHP4用户手册:函数-flock

PHP4用户手册:函数-flock

Jun 13, 2016 am 10:22 AM
flockintphpfunctionmanualdocumentuserlocking

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 脚本正在同一的服务器的实例中平行线程中运行。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools