Here I demonstrate the ability for PHP to save files, with both the PHP 5 and PHP 4 method. Using file_put_contents() I can save files, or I can use fopen(), fwrite(), and fclose() to save a file. Naturally it is easier to use the single function available in the latest PHP build. If you want to refer back to the previous tutorial where I demonstrated loading files, you can see how these two pretty much go together.
Here are the sources used in this tutorial:
tut029.php
<?php //PHP Tutorial 029 Saving Files //PHP 5 method and earlier. $data = "my socks rock like the sky"; $filename = "test2.txt"; //in PHP 5 you can use the below line to save a file file_put_contents($filename, $data); //in PHP 4 you can use the below to save a file $fh = fopen($filename, "w"); fwrite($fh, $data); fclose($fh); ?>