Is there a risk in running file_put_contents() on the same file from different PHP threads?
<p>I know <a href="http://us.php.net/file_put_contents" rel="nofollow">file_put_contents()</a> makes it really easy to append data to a file in PHP. I'd like to try using PHP "<a href="http://www.funkynerd.com/knowledgebase/articles/2" rel="nofollow">threads</a>" to <code>file_put_contents()</code> to the same log file from different PHP threads. Is there a risk in running file_put_contents() on the same file from different PHP threads or will these threads happily block if the file is locked or being accessed by another thread?</p>

<p>EDIT: Found <a href="http://stackoverflow.com/questions/4682533/two-users-write-to-a-file-at-the-same-time-php-file-put-contents">a similar question</a> that recommends <a href="http://www.php.net/manual/en/function.flock.php" rel="nofollow">flock()</a>, but the risk question does not seem to be fully addressed. Are these "atomic" write operations?</p>
