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:
Rasmus Lerdorf 2009-07-01 20:15:16 +00:00
parent da86ca4641
commit 81d318ad96

View file

@ -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);