可能重复:
解析 PHP 代码以提取函数名称?
我正在编写一个脚本来读取我的 PHP 文件并获取所有函数作为返回。
我preg_split()
用来将我的文件拆分为一组函数。
我在编写模式以获取所有返回的函数时遇到问题(当函数名称包含“函数”一词时遇到问题。我愿意接受任何其他解决方案/建议。
预期输出:
array (
0 => 'function write{$oneparam, $two, $three){return $two}',
1 => 'function read{$oneparam, $two, $tthree){returne $awesome}',
2 => 'function edit{$oneparam, $two, $three){return $two},
3 => 'function delete{$oneparam, $two, $three){return $two}',
4 => 'function lastfunction{$oneparam, $two, $three){return $two}'
)