Home > Backend Development > PHP Tutorial > php项目中常用的log日志记录方法

php项目中常用的log日志记录方法

WBOY
Release: 2016-06-23 13:32:05
Original
1259 people have browsed it

/** * ****************** * 1、写入内容到文件,追加内容到文件 * 2、打开并读取文件内容 * ******************* */function save_log($path, $msg){    if (! is_dir($path)) {        mkdir($path);    }    $filename = $path . '/' . date('YmdHi') . '.txt';    $content = date("Y-m-d H:i:s")."\r\n".$msg."\r\n \r\n \r\n ";    file_put_contents($filename, $content, FILE_APPEND);}save_log('./chenghuan', 'aaaaaaaaaaaaaaaaaaaaaaa');
Copy after login


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template