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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:32:051292browse

/** * ****************** * 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');


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