Last active
December 15, 2015 08:49
-
-
Save cdmo/5233404 to your computer and use it in GitHub Desktop.
logging object/array/variable dumps to a file in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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