首页 > php教程 > php手册 > PHP写日志函数,php日志函数

PHP写日志函数,php日志函数

WBOY
发布: 2016-06-13 08:40:00
原创
1594 人浏览过

PHP写日志函数,php日志函数

  初学,写一个函数用于存储日志调试。

<span> 1</span>     <span>function</span> WriteLog(<span>$msg</span><span>)
</span><span> 2</span> <span>    {
</span><span> 3</span>         <span>$filename</span> = <span>dirname</span>(<span>__FILE__</span>) ."\\Debug.log"<span>;
</span><span> 4</span>         <span>$handler</span> = <span>null</span><span>;
</span><span> 5</span> 
<span> 6</span>         <span>if</span> ((<span>$handler</span> = <span>fopen</span>(<span>$filename</span>, 'ab+')) !== <span>false</span><span>)
</span><span> 7</span> <span>        {
</span><span> 8</span>             <span>fwrite</span>(<span>$handler</span>, '['.<span>date</span>('Y-m-d H:i:s').']'."\t".<span>$msg</span>."\n"<span>);
</span><span> 9</span>             <span>fclose</span>(<span>$handler</span><span>);
</span><span>10</span> <span>        }
</span><span>11</span>     }
登录后复制

 

  

相关标签:
php
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板