note 44150 deleted from function.file-put-contents by aidan

From: Date: Fri, 16 Jul 2004 10:30:47 +0000
Subject: note 44150 deleted from function.file-put-contents by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73367@lists.php.net to get a copy of this message
Note Submitter: luke at hpad dot com ---- // 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; }

« previous php.notes (#73367) next »