file_put_contents() for PHP4
Simplified, but still...
if (!function_exists('file_put_contents')) { function file_put_contents($filename, $data) { $f = @fopen($filename, 'w'); if (!$f) { return false; } else { $bytes = fwrite($f, $data); fclose($f); return $bytes; } } }
This entry was posted on Monday, September 10th, 2007 and is filed under php. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

September 11th, 2007 at 7:08 am
Shouldn’t the title be file_put_contents?
September 11th, 2007 at 12:57 pm
oops, thanks Adam!
December 1st, 2007 at 11:18 am
Thanks very much – a useful function!
January 17th, 2008 at 10:09 am
[...] a bit more research and I found out that the function which appears in the script from B&T’s Tips & Scripts: file_put_contents() works with PHP5 but not with PHP4 which is what I have. Some googling for “file_put_contents() for PHP4″ brings up quite a few implementations of the PHP5 file_put_contents() function for PHP4. The one I settled for can be found in Stoyan Stefanov’s blog phppied.com (thanks Stoyan!) [...]
February 12th, 2008 at 5:53 pm
thanks very much, it was very usefull for me
May 20th, 2008 at 8:24 am
(“Beginner”) Can you explain this a bit?
If I have file_put_contents(“$archiveDir/$archiveFilename”, $output); how do I make it work using this?
September 25th, 2008 at 1:12 pm
Very usefull, thank you very much!