Saving files to disk is a pretty simple task in PHP with
file_put_contents(). Here’s how to write a string to a file:
It is generally good practice to only do with when you are dealing with smaller strings as you can run into memory errors if you are trying to assemble a super large string. In situations where this may occur, you can rely on our trusty filesystem functions and write to the file line by line:
For the most part
file_put_contents will get the job done, but if not, you can still get the job done!