note 44150 added to function.file-put-contents

From: Date: Fri, 16 Jul 2004 05:42:40 +0000
Subject: note 44150 added to function.file-put-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-73350@lists.php.net to get a copy of this message
// Checking file is writable first // then locking file for writeout // binary safe function file_put_contents($fileName, $data) { // Check file is writable if (! is_writeable($fileName)) return false; // Exclusive lock @flock($fp, LOCK_EX); // Open pointer to file if (($fp = @fopen($fileName, 'wb')) === false) return false; // Write data to file pointer if (($bytes = @fwrite($fp, $data)) === false) return false; // Close file @fclose($fp); // unlock @flock($fp, LOCK_UN); return $bytes; } ---- Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44150 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44150&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44150&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73350) next »