rendered paste body<?php
if(!function_exists('file_put_contents')) {
function file_put_contents($filename, $data, $append=false, $lock=false) {
/* {{{ Puts $data into $filename */
if(!is_readable($filename)) {
return false;
}
if(empty($data)) { return false; }
if($append) {
$fp = @fopen($filename, 'a');
} else {
$fp = @fopen($filename, 'w');
}
if(!$fp) { return false; }
if($lock) {
if(!flock($fp, LOCK_EX)) {
fclose($fp);
return false;
}
}
if(!fwrite($fp, $data)) {
if($lock) { @flock($fp, LOCK_UN); }
@fclose($fp);
return false;
}
if($lock) {
flock($fp, LOCK_UN);
}
fclose($fp);
return true;
/* }}} */
}
}
file_put_contents('test.txt', 'hello!', true);