note 35462 added to function.file-put-contents

From: Date: Mon, 01 Sep 2003 21:22:23 +0000
Subject: note 35462 added to function.file-put-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-55444@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35462 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35462&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35462&report=yes

« previous php.notes (#55444) next »