public static function log($var, $file = ''){
$file = LOG_PATH . 'static' . '/' . 'log' . '/' .
($file ? $file . '_' : $file) . date('Ymd') . '.log';
$str = self::encodeObject($var);
error_log(DTF . ' ' . $str . "\n", 3, $file);
}
private static function encodeObject($Object){
$str = '';
if (is_resource($Object) || is_object($Object)) {
$str = '** '.(string)$Object.' **';
} elseif (is_array($Object)) {
foreach ($Object as $key => $val) {
$str .= $key . '::::' . self::encodeObject($val) . '\n';
}
} else {
$str = (string)$Object;
}
return $str;
}
php 写入日志函数
最新推荐文章于 2024-06-12 15:32:35 发布