php怎么写日志?php实现的简单日志写入函数

作者:袖梨 2022-06-24

 

 代码如下复制代码

functionlog($logthis){

file_put_contents('logfile.log',date("Y-m-d H:i:s")." ".$logthis."rn", FILE_APPEND | LOCK_EX);

}

// use rn for new line on windows, just n on linux

// PHP_EOL cross platform solution for new line

// // so better to use this

functionlog($logthis){

file_put_contents('logfile.log',date("Y-m-d H:i:s")." ".$logthis.PHP_EOL, FILE_APPEND | LOCK_EX);

}

 

相关文章

精彩推荐