note 78263 added to function.file-put-contents

From: Date: Thu, 04 Oct 2007 19:20:36 +0000
Subject: note 78263 added to function.file-put-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-131089@lists.php.net to get a copy of this message
I was in need of a function that updated the last modified date in a php file. There may be a better way, but this is how I did it: <?php function updateFile($modFile){ if(!empty($modFile)){ if($fo = fopen($modFile, 'r')){ $source = ''; while (!feof($fo)) { $source .= fgets($fo); } file_put_contents($modFile,$source); fclose($fo); } } } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 68.157.226.218 ---- Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php Edit -- https://master.php.net/note/edit/78263 Del: integrated -- https://master.php.net/note/delete/78263/integrated Del: useless -- https://master.php.net/note/delete/78263/useless Del: bad code -- https://master.php.net/note/delete/78263/bad+code Del: spam -- https://master.php.net/note/delete/78263/spam Del: non-english -- https://master.php.net/note/delete/78263/non-english Del: in docs -- https://master.php.net/note/delete/78263/in+docs Del: other reasons-- https://master.php.net/note/delete/78263 Reject -- https://master.php.net/note/reject/78263 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131089) next »