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

  1. functionlog($logthis){
  2. file_put_contents('logfile.log',date("Y-m-d H:i:s")." ".$logthis."\r\n", FILE_APPEND | LOCK_EX);
  3. }
  4. // use \r\n for new line on windows, just \n on linux
  5. // PHP_EOL cross platform solution for new line
  6. // // so better to use this
  7. functionlog($logthis){
  8. file_put_contents('logfile.log',date("Y-m-d H:i:s")." ".$logthis.PHP_EOL, FILE_APPEND | LOCK_EX);
  9. }