Simplified, but still…
<?php
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.
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