mirror of
https://github.com/e107inc/e107.git
synced 2025-06-03 01:15:03 +02:00
Support append on file_put_contents() emulation
This commit is contained in:
parent
74fd54fdf1
commit
6000dba853
@ -12,18 +12,26 @@ if (!function_exists('file_put_contents')) {
|
||||
* @param mixed $data
|
||||
* @desc Write a string to a file
|
||||
*/
|
||||
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;
|
||||
define('FILE_APPEND', 1);
|
||||
function file_put_contents($filename, $data, $flag = false)
|
||||
{
|
||||
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
|
||||
if (($h = @fopen($filename, $mode)) === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (is_array($data)) $data = implode($data);
|
||||
if (($bytes = @fwrite($h, $data)) === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
fclose($h);
|
||||
return $bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('stripos')) {
|
||||
function stripos($haystack, $needle) {
|
||||
$parts = explode(strtolower($needle), strtolower($haystack), 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user