本文實(shí)例講述了php實(shí)現(xiàn)的簡單日志寫入函數(shù)。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
function log( $logthis ){
file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis. "\r\n", FILE_APPEND | LOCK_EX);
}
// use \r\n for new line on windows, just \n on linux
// PHP_EOL cross platform solution for new line
// // so better to use this
function log( $logthis ){
file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis.PHP_EOL, FILE_APPEND | LOCK_EX);
}
更多信息請查看IT技術(shù)專欄