php 5.2-查询路径,php 5.2


php 5.2 - Query path, php 5.2

我在PHP中使用Querypath。由于我的linux是Debian Lenny,它不再支持,我也不知道如何将其更新为Debian Squeeze。我无法更新它的php,因为它不存在于Lenny(就我所读的内容而言)。

使用Querypath我得到这个错误:

分析错误:语法错误,意外的T_FUNCTION,中应为")"/var/www/vhosts/company/httpdocs/2013/inc/qp.php第61行

这行是:

spl_autoload_register(function ($klass) {
 $parts = explode('''', $klass);
 if ($parts[0] == 'QueryPath') {
 $path = __DIR__ . '/' . implode('/', $parts) . '.php';
  if (file_exists($path)) {
    require $path;
  }
}

你知道吗,热我可以把它转换成"PHP 5.2.6-1+lenny13版本"?

PHP 5.2不支持匿名函数。

相反,尝试使用一个命名函数,用字符串表示:

function my_function($kclass) {
    $parts = explode('''', $klass);
    if ($parts[0] == 'QueryPath') {
        $path = __DIR__ . '/' . implode('/', $parts) . '.php';
        if (file_exists($path)) {
            require $path;
        }
    }
}
spl_autoload_register('my_function');