Return to Snippet

Revision: 8912
at October 13, 2008 21:34 by mischachen


Updated Code
if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) {
	define('FILE_APPEND', 1);
	function file_put_contents($n, $d, $flag = false) {
	    $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
	    $f = @fopen($n, $mode);
	    if ($f === false) {
	        return 0;
	    } else {
	        if (is_array($d)) $d = implode($d);
	        $bytes_written = fwrite($f, $d);
	        fclose($f);
	        return $bytes_written;
	    }
	}
}

Revision: 8911
at October 13, 2008 21:32 by mischachen


Initial Code
if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') ) {
	define('FILE_APPEND', 1);
	function file_put_contents($n, $d, $flag = false) {
	    $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
	    $f = @fopen($n, $mode);
	    if ($f === false) {
	        return 0;
	    } else {
	        if (is_array($d)) $d = implode($d);
	        $bytes_written = fwrite($f, $d);
	        fclose($f);
	        return $bytes_written;
	    }
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
file_put_contents

Initial Tags
textmate, log

Initial Language
PHP