Since flock() requires a file pointer, you may have to use a special lock file to protect access to files intended to be opened in write mode (adding "w" or "w+" to the fopen() function).
Since flock() requires a file pointer, you may have to use a special lock file to protect access to files intended to be opened in write mode (adding "w" or "w+" to the fopen() function).
fp = fopen("test.txt", 'ab'); //from the end
flock($fp, lock_ex); //lock the file for waiting...
fwrite($fp, 'just a test string....'); //start writing...
flock($fp, lock_un);
fclose($fp);
//read
flock($fp, lock_sh);
//read from the file......
flock($fp, lock_un);