← All Articles

How to Write to a file in PHP

Posted on

The simplest way of writing to a file in php is using the fileputcontents function. This implicitly calls fopen, fwrite and fclose, as we know from e.g. c.

file_put_contents("outfile.txt", "This is a string, but it could have been an array or a stream as well");