note 35462 deleted from function.file-put-contents by sniper
| From: | sniper@php.net | Date: | Sat, 03 Jan 2004 02:48:11 +0000 |
| Subject: | note 35462 deleted from function.file-put-contents by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62840@lists.php.net to get a copy of this message | ||
Note Submitter: X-Istence.com
----
Since in < PHP 5 there isnt any function like this i wrote one of my own for you people that
would want to use it.
<?php
function file_put_contents_php4 ($location, $whattowrite) {
if (file_exists($location)) {
unlink($location);
}
$fileHandler = fopen ($location, "w");
fwrite ($fileHandler, $whattowrite);
fclose ($fileHandler);
}
?>
Just a few notes:
1. This is not binary safe
2. It will delete the file it is gonna write to before it writes to it