获取当前目录下所有php文件内的函数名

$dir =  dirname(__FILE__);

$files = scandir($dir);

foreach($files as $name){
if($name == '.' || $name == '..'){ continue; }
$title = preg_replace("/Controller.*?php/",'',$name);
$file = fopen($name,"r"); $content = array(); while(!feof($file)){
$line_content = fgets($file);
preg_match("/public\s+function/", $line_content, $pat_array);
if(isset($pat_array[0])){
$line_content = preg_replace("/.*?function\b|\(.*?{|\s+/",'',$line_content); $content[] = $title.'/'.$line_content; } } fclose($file); print_r($content); }

 

posted @ 2019-03-06 13:19  没有昵称不想想  阅读(517)  评论(0编辑  收藏