首页 >后端开发 >php教程 >PHP写日志函数,php日志函数_PHP教程

PHP写日志函数,php日志函数_PHP教程

WBOY
WBOY原创
2016-07-12 08:52:32926浏览

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>     }

 

  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1126173.htmlTechArticlePHP写日志函数,php日志函数 初学,写一个函数用于存储日志调试。 1 function WriteLog( $msg ) 2 { 3 $filename = dirname ( __FILE__ ) ."\\Debug.log" ; 4 $hand...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn