|
Posted by Colin McKinnon on 03/03/07 23:21
Efi Merdler wrote:
> Hi,
> I created a very simple application that reads and writes to a file, I
> was wondering if fopen when opening a file for write access blocks
> this file, i.e. when another user runs this script the script will
> halt until the first user closes its file handle.
>
What happenned when you tested it?
Here's a hint:
<?php
print "ready to start\n";
flush();
$fh=fopen('/tmp/test','w');
if (is_resource($fh)) {
print "opened...\n";
flush();
sleep(30);
print "Exiting\n";
fclose($fh);
} else {
print "failed to open\n";
}
?>
(if you run two instances of this script, the second will do one of three
things - you've only considered two possibilities so far)
> If not how can I change php behavior to block such access?
>
flock()
C.
Navigation:
[Reply to this message]
|