I have a PHP script that occasionally needs to write large files to disk. Using file_put_contents(), if the file is large enough (in this case around 2 MB), the
file_put_contents()
Writing line by line (or packet by packet in case of binary files) using functions like fwrite()
fwrite()