mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Don't use w+ in the example here
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@283282 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
da86ca4641
commit
81d318ad96
1 changed files with 4 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<!-- $Revision: 1.18 $ -->
|
||||
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.flock">
|
||||
<refnamediv>
|
||||
<refname>flock</refname>
|
||||
|
@ -130,13 +130,14 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$fp = fopen("/tmp/lock.txt", "w+");
|
||||
$fp = fopen("/tmp/lock.txt", "w");
|
||||
|
||||
if (flock($fp, LOCK_EX)) { // do an exclusive lock
|
||||
ftruncate($fp, 0); // truncate file
|
||||
fwrite($fp, "Write something here\n");
|
||||
flock($fp, LOCK_UN); // release the lock
|
||||
} else {
|
||||
echo "Couldn't lock the file !";
|
||||
echo "Couldn't get the lock!";
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
|
Loading…
Reference in a new issue