您的位置:首页 > 其它

函数file_put_contents();详解与实例

2017-12-19 17:07 786 查看
    
//对unicode码再进行解码,否则写进日志的不是中文
function decodeUnicode($str)
{
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i',
create_function(
'$matches',
'return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");'
),
$str);
}
function addlog( $reqsn , $msg ){

$logarray['data'] = date("Y-m-d H:i:s");
$logarray['reqsn'] = $reqsn;
$logarray['msg'] = $msg;
$josnstr = decodeUnicode(json_encode($logarray));

file_put_contents("./uplogs/payLogs.txt", $josnstr.PHP_EOL, FILE_APPEND);
}


     
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: