php的debug相關(guān)函數(shù)用法示例

字號(hào):


    這篇文章主要介紹了php的debug相關(guān)函數(shù),可實(shí)現(xiàn)針對(duì)登陸信息的記錄功能,涉及debug_backtrace函數(shù)及數(shù)組、字符串相關(guān)操作技巧,需要的朋友可以參考下
    loginfo函數(shù):
    function loginfo($format) {
      $args = func_get_args();
      array_shift($args);
      $d = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1)[0];
      $info = vsprintf($format, $args);
      $data = sprintf("%s %s,%d: %s\n", date("Ymd His"), $d["file"], $d["line"], $info);
      file_put_contents(__DIR__."/log.txt", $data, FILE_APPEND);
    }
    希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。