Home >php教程 >php手册 >最简易的日志函数,哈哈

最简易的日志函数,哈哈

WBOY
WBOYOriginal
2016-06-07 11:34:171374browse

可以写入普通日常系统对接中的发送数据,或者响应数据,等!
/**<br>  * $file 文件名<br>  * $content 日志内容<br>  */<br> function MyWriteLog($file, $content)<br> {<br>     try {<br>         $directory = config('log_path');//日志目录,根据自己的需求修改,也可以不要<br>         $date = date('Ymd');<br>         //$date = date('Y.m.d');<br>         $filename = sprintf("%s/" . $file . '.' . $date . ".log", $directory);<br>         $fp = fopen($filename, 'a+');<br>         $filecontent = $content;<br>         fwrite($fp, PHP_EOL . $filecontent);<br>         fclose($fp);<br>     } catch (Exception $e) {<br>         echo $e;<br>     }<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn