note 41259 added to function.file-put-contents

From: Date: Sun, 04 Apr 2004 18:44:52 +0000
Subject: note 41259 added to function.file-put-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-67627@lists.php.net to get a copy of this message
There is a function that doesn't replace file_put_contents, but some might find it just as easy to use, and it's a bit better, thought might be slower Description etc is here: http://mctrafik.net/?i=15 but the function looks kinda like this: <? function writetofile($file, $data, $keep = false) { if($keep) { $handle = @fopen($file, "r"); if($handle) { $precont = fread($handle, filesize($file)); fclose($handle); } } ignore_user_abort(true); $handle = @fopen($file, "w") or die("Permission denied to write to " . $file); @flock ($handle, LOCK_EX); fwrite($handle, trim($data)); if($keep) { fputs ($handle, "\n" . $precont); } @flock ($handle, LOCK_UN); fclose($handle); ignore_user_abort(false); unset($precont); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41259 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41259&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41259&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67627) next »