函数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); }
相关文章推荐
- 【php】PHP中file_get_contents()与file_put_contents()函数细节详解
- file_put_contents() 与 file_get_contents() 函数用法
- 深入php函数file_get_contents超时处理的方法详解
- 深入php函数file_get_contents超时处理的方法详解
- SAE虽然禁止了IO写操作,但是并没有禁止fwrite,file_put_contents等写操作函数
- PHP fwrite() 函数与 file_put_contents() 函数的比较
- file_put_contents()函数
- SAE平台fwrite,file_put_contents等函数写操作
- 比 file_get_contents() 更优的 cURL 详解(附实例)
- PHP文件写入函数file_put_contents并发追加写入丢失内容问题解决方法
- PHP中file_put_contents()函数的兼容性问题
- ThinPHP第二十八天(F函数和file_put_contents区别|PHP生成PHP文件,Kindeditor编辑器使用方法)
- php-file_put_contents() 函数
- PHP文件操作,多行句子的读取,file()函数,file_get_contents()函数,file_put_contents()函数,is_file,统计网站pv (访问量),文件的复制 copy
- 使用php中ob函数和file_put_contents生成简单静态页的类
- php基于curl重写file_get_contents函数实例
- 超强功能file_put_contents()函数(集成了fopen、fwrite、fclose)
- Oracle排名函数(Rank)实例详解
- linux网络编程常用函数详解与实例(socket-->bind-->listen-->accept)
- "Fatal error: Call to undefined function: file_put_contents()"