优化xdebug函数,以兼容更高版本php;

This commit is contained in:
augushong
2021-12-01 16:24:36 +08:00
parent 9198d94738
commit 3685224d6a

View File

@@ -55,7 +55,21 @@ if (!function_exists('xdebug')) {
$file = is_null($suffix) ? runtime_path() . 'xdebug/' . date('Ymd') . '.txt' : runtime_path() . 'xdebug/' . date('Ymd') . "_{$suffix}" . '.txt';
}
file_put_contents($file, "[" . date('Y-m-d H:i:s') . "] " . "========================= {$type} ===========================" . PHP_EOL, FILE_APPEND);
$str = (is_string($data) ? $data : (is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true)) . PHP_EOL;
$str = '';
if(is_string($data)){
$str = $data;
}else{
if(is_array($data) || is_object($data)){
$str = print_r($data, true);
}else{
$str = var_export($data, true);
}
}
$str . PHP_EOL;
$force ? file_put_contents($file, $str) : file_put_contents($file, $str, FILE_APPEND);
}
}