欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php如何實(shí)現(xiàn)不借助IDE快速定位行數(shù)或者方法定義的文件和位置

 更新時(shí)間:2017年01月17日 17:27:08   投稿:lqh  
這篇文章主要介紹了php如何實(shí)現(xiàn)不借助IDE快速定位行數(shù)或者方法定義的文件和位置的相關(guān)資料,需要的朋友可以參考下

php 如何實(shí)現(xiàn)不借助IDE快速定位行數(shù)或者方法定義的文件和位置

借助了ReflectionMethod的一些特性,可以快速獲得函數(shù)或者方法是在哪個(gè)文件的什么位置定義的,對于調(diào)試沒有文檔的程序來說很有幫助!

function function_dump($funcname) {
  try {

    if(is_array($funcname)) {
      $func = new ReflectionMethod($funcname[0], $funcname[1]);
      $funcname = $funcname[1];
    } else {
      $func = new ReflectionFunction($funcname);
    }
    
  } catch (ReflectionException $e) {
    echo $e->getMessage();
    return;
  }

  $start = $func->getStartLine() - 1;

  $end = $func->getEndLine() - 1;

  $filename = $func->getFileName();

  echo "function $funcname defined by $filename($start - $end)\n";
}

使用:

function_dump('get_affiliate');

輸出:

function get_affiliate defined by D:\WWW\admin\affiliate.php(232 - 238)

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評(píng)論