note 44048 added to function.fwrite

From: Date: Tue, 13 Jul 2004 15:02:04 +0000
Subject: note 44048 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-73163@lists.php.net to get a copy of this message
A rapid way to add content to a file is to use file_put_contents(), available in PHP 5. If you're using a version of PHP prior to 5, you may use PEAR::PHP_Compat, which provides this function. If you don't have PEAR::PHP_Compat or you don't want to use it for whatever reason, here's my implementation of this function in versions of PHP < 5: <?php if (!function_exists('file_put_contents')) { function file_put_contents($filename, $data) { if (($h = @fopen($filename, 'w')) === false) { return false; } if (($bytes = @fwrite($h, $data)) === false) { return false; } fclose($h); return $bytes; } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.fwrite.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44048 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44048&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44048&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73163) next »