Skip to content

Instantly share code, notes, and snippets.

@cdmo
Last active December 15, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmo/5233404 to your computer and use it in GitHub Desktop.
Save cdmo/5233404 to your computer and use it in GitHub Desktop.
logging object/array/variable dumps to a file in PHP
<?php
function log_to_file($text) {
$f = fopen('/tmp/my_log.txt', 'a');
fwrite($f, date('Ymd H:i:s - ') . $text . "\n");
fclose($f);
}
// to print arrays/objects use
// log_to_file(print_r($obj, $return = TRUE));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment