PHP调试函数

  • 该函数可以替代var_dump
  • 每次使用会输出调用地址
function ds($val,...$param) {
    $call_info = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    if (isset($call_info[0]['file'])) {
        $call_info = "{$call_info[0]['file']} | {$call_info[0]['line']}";
    }else{
        $call_info = '';
    }

    echo "<font size='1'>{$call_info}</font>";
    echo "<pre>";
    dump($val,...$param);
    echo "</pre>";
    exit("exit ^");
}

添加新评论