Skip to content

Instantly share code, notes, and snippets.

@Braunson
Last active August 29, 2015 14:12
Show Gist options
  • Save Braunson/42d2b507a160c5bb38f6 to your computer and use it in GitHub Desktop.
Save Braunson/42d2b507a160c5bb38f6 to your computer and use it in GitHub Desktop.
Quick write to file with date/time, very crude.
function logToFile($msg) {
$filename = 'logfile.log';
if(is_array($msg)){
file_put_contents($filename, print_r($msg, true), FILE_APPEND);
} else {
$fd = fopen($filename, "a");
$str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg;
fwrite($fd, $str . "\n");
fclose($fd);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment