Home >Backend Development >PHP Tutorial >PHP writing log function, php log function_PHP tutorial

PHP writing log function, php log function_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:52:32929browse

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