note 43565 modified in function.file-put-contents by ramsey

From: Date: Fri, 25 Jun 2004 18:34:18 +0000
Subject: note 43565 modified in function.file-put-contents by ramsey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71695@lists.php.net to get a copy of this message
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; } } ?> --was-- 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) { $h = @fopen($filename, 'w'); if ($h === false) { return false; } $bytes = fwrite($h, $data); fclose($h); return $bytes; } } ?> http://php.net/manual/en/function.file-put-contents.php

« previous php.notes (#71695) next »