Forum Moderators: coopster

Message Too Old, No Replies

PHP file handling. 2 questions.

flock access

         

smagdy

11:23 am on Apr 7, 2006 (gmt 0)

10+ Year Member



HEllo,

1) Suppose that process A locks "file1" using flock()for writing, and process B wants to write to "file1"... what will happen?

- of course i want process B to write after process A finish.. so is it done automatically or should i do it by a way or another?

2) When i use file('myfile.txt');
does it need flock() and fclose?

Thanks in advance

coopster

12:40 pm on Apr 7, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



  1. The second process will wait a bit to acquire a lock. If it cannot, the flock will return FALSE.
  2. You need to use fopen to get a file handle resource when using flock, so you won't be able to use file() with flock().