RE: [PHP] flock again
| From: | WILSON, Nick | Date: | Fri, 20 Oct 2000 01:55:40 +0000 |
| Subject: | RE: [PHP] flock again | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-21316@lists.php.net to get a copy of this message | ||
I think the way to use it is not test for flock, the flock
will just wait until the lock has been released, you don't
really need to test the flock, if it's locked then it will
wait until the lock is released.
$fp=fopen("cool.dat", "w");
flock($fp,2))
{
fputs($fp, "cool it works");
}
fclose($fp);
If one php script is running and has accessed the file and locked
it, then another identical script starts running, it will simply
wait at the flock statement until the lock for $fp has been released.
I tested it with one file writing to a file and then another one
writing something different over the top of it and both text appeared
in the file,
Hope this helps,
Nick
> -----Original Message-----
> From: Tan Minh TRUONG [mailto:truong_tan_minh@hotmail.com]
> Sent: Friday, 20 October 2000 12:11
> To: php-general@lists.php.net
> Subject: [PHP] flock again
>
>
> flock seems to be impossible,
> even for a new file.
>
> I create a new file, and I can't lock it.
>
> WHY ?
>
> Minh
>
> $fp=fopen("cool.dat", "w");
> if(!flock($fp,2))
> {
> print("why<BR>\n");
> }
> fputs($fp, "cool it works");
> if(!flock($fp,3))
> {
> print("rewhy<BR>\n");
> }
> fclose($fp);
> ______________________________________________________________
> ___________
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net