我有这样的功能:
function test($str,$func) {
$func($str);
//Something more here
}
Run Code Online (Sandbox Code Playgroud)
我怎么能在那里传递一个函数名?我想做test("Hello",strtolower);或喜欢test("Bye",sometextprocessfunc);
这是我的目录树:
在我的head.php和connect.php都有:
include_once 'include/functions.php';
Run Code Online (Sandbox Code Playgroud)
我在根文件夹中的index.php包括以下两个:head.php和connect.php,如下所示:
include_once 'include/connect.php';
include_once 'include/head.php;'
Run Code Online (Sandbox Code Playgroud)
但是,当sub /中的index.php包含functions.php和head.php时,它们将无法包含functions.php.这是我在sub/index.php中包含的内容:
include_once '../include/connect.php';
include_once '../include/head.php';
Run Code Online (Sandbox Code Playgroud)
如果我将head.php和connect.php更改为:include_once'../include/functions.php';
sub/index.php通常会包含所有内容,但root中的index.php将无法加载functions.php.
我怎样才能解决这个问题?
PHP版本:5.2.*
php ×2