note 105879 modified in function.flock by danbrown

From: Date: Thu, 22 Sep 2011 15:51:33 +0000
Subject: note 105879 modified in function.flock by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183348@lists.php.net to get a copy of this message
I just spend a long time to understand why write function returns me "0", on a basic file opening and then writing. I discovered that if you use LOCK_SH and then you write something, that will not work : <?php $fp = fopen('file.txt', 'a'); flock($fp,LOCK_SH); $written = fputs($fp, 'data'); var_dump($written); // 0 and file is not changed fclose($fp); ?> --was-- I just spend a long time to understand why write function returns me "0", on a basic file opening and then writing. I discovered that if you use LOCK_SH and then you write something, that will not work : $fp = fopen('file.txt', 'a'); flock($fp,LOCK_SH); $written = fputs($fp, 'data'); var_dump($written); // 0 and file is not changed fclose($fp); http://php.net/manual/en/function.flock.php

« previous php.notes (#183348) next »