Simple logger function


/ Published in: PHP
Save to your folder(s)

Simple logger function


Copy this code and paste it in your HTML
  1. function log( $logthis ){
  2. file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis. "
  3. ", FILE_APPEND | LOCK_EX);
  4. }
  5.  
  6. // use
  7. for new line on windows, just \n on linux
  8. // PHP_EOL cross platform solution for new line
  9. // // so better to use this
  10.  
  11. function log( $logthis ){
  12. file_put_contents('logfile.log', date("Y-m-d H:i:s"). " " . $logthis.PHP_EOL, FILE_APPEND | LOCK_EX);
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.