I am logging visitor custom search queries to a text file as follows:
define('SEARCH_LOG', 'log.txt');
file_put_contents(SEARCH_LOG, "\n" . $search, FILE_USE_INCLUDE_PATH | FILE_APPEND);
Every 100 searches, I sort and collate the entries and email them to the site owner. Then I clear the file as follows:
file_put_contents(SEARCH_LOG, "", FILE_USE_INCLUDE_PATH);
I understand that file_put_contents is identical to calling fopen(), fwrite(), and fclose() successively.
Do I need to worry about collisions between users or is this somehow handled for me?
Do I need to write a conditional retry?
Should I use the
LOCK_EXflag?