我有几个 PHP 文件,里面有多个函数。我们称它们为functions1.php、functions2.php、functions3.php:
function function_something( $atts ) {
extract( something_atts( array(
'foo' => 'bar',
'bar' => 'foo,
), $atts ) );
return 'something';
}
我在 all_functions.php 中加载这些文件,如下所示:
require_once('functions1.php');
require_once('functions2.php');
require_once('functions3.php');
我想知道是否可以创建一个包含所有这些函数及其属性的数组?
我正在考虑类似的事情:
function my_functions() {
require_once('functions1.php');
require_once('functions2.php');
require_once('functions3.php');
}
然后是一些 foreach 循环,但我不确定它到底应该是什么样子。
我知道这可能看起来很棘手,但我只是好奇我是否能够在没有 PHP 反射 API 的情况下列出我所有的 WordPress 短代码 :)