I\'m trying to create a function (for purposes of logging)
append($path, $data)
that
using PHP's internal function http://php.net/manual/en/function.file-put-contents.php
file_put_contents($file, $data, FILE_APPEND | LOCK_EX);
FILE_APPEND => flag to append the content to the end of the file
LOCK_EX => flag to prevent anyone else writing to the file at the same time (Available since PHP 5.1)
PHP already has a built-in function to do this, file_put_contents(). The syntax is:
file_put_contents($filename, $data, FILE_APPEND);
Note that file_put_contents()
will create the file if it does not already exist (as long as you have file system permissions to do so).