note 99317 deleted from function.file-put-contents by danbrown

From: Date: Tue, 10 Aug 2010 15:16:56 +0000
Subject: note 99317 deleted from function.file-put-contents by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171532@lists.php.net to get a copy of this message
Note Submitter: mdmitry at gmail dot com ---- PHP4 emulation including all flags: <?php if (!function_exists('file_put_contents')) { $_defines = array( 'FILE_USE_INCLUDE_PATH' => 1, 'FILE_APPEND' => 8, 'LOCK_EX' => 2 ); foreach ($_defines as $_k=>$_v) if (!defined($_k)) define($_k, $_v); function file_put_contents($filename, $data, $flags=0) { $ret = false; $f = @fopen($filename, ($flags & FILE_APPEND) ? 'ab' : 'wb', $flags & FILE_USE_INCLUDE_PATH); if ($f) { if ($flags & LOCK_EX) { if (flock($f, LOCK_EX)) { $ret = fwrite($f, $data); flock($f, LOCK_UN); } } else $ret = fwrite($f, $data); fclose($f); } return $ret; } } ?>

« previous php.notes (#171532) next »