PHP反射查找自定义函数

在PHP中,通过反射,可以方便地查找某个自定义函数所在的文件名,便于调试。同时还能得到该函数需要
传递的参数。

Reflection::export

直接上代码:

<?php
 $funcName="SafeHtml"; //要查找的函数名
 Reflection::export(new ReflectionFunction($funcName));//直接显示

 //写入文件
 $str = Reflection::export(new ReflectionFunction($funcName), TRUE);
 file_put_contents('d:mylog.txt', $str , FILE_APPEND);
?>

输出如下:

Function [ <user> function SafeHtml ] {
  @@ D:wampwwwlibsglobal.func_utf8_sql.php 94 - 118

  - Parameters [2] {
    Parameter #0 [ <optional> $msg = '' ]
    Parameter #1 [ <optional> $clear_script = true ]
  }
}
原文地址:https://www.cnblogs.com/fenle/p/4467745.html