Last active
August 29, 2015 14:15
-
-
Save Chengings/c7a4d4cae5abeb01b782 to your computer and use it in GitHub Desktop.
Insert the string output to log file
This file contains 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 | |
private function _logfile($logName, $str2log) | |
{ | |
$file= sys_get_temp_dir() . '/mydebug-' . date('Y-m-d') . '.log'; | |
if (!$handle = fopen($file, 'a')) { | |
throw new Exception('Could not open file!'); | |
} | |
$str2log = print_r($str2log, true); | |
$olog = print_r("{$logName}: {$str2log}", true) . PHP_EOL; | |
if(fwrite ($handle, $olog)===false){ | |
throw new Exception('Could not write file!'); | |
} | |
fclose($handle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment