1

我正在使用此代码在我的 CMS 中获取模块信息:

global $hook;
$hook = new bn_hookfunc;

ob_start();
include_once($mydir);
ob_end_clean();
$mod_name = $hook->call_function('module_name');
$mod_ver  = $hook->call_function('module_version');

我的模块 config.php 看起来像这样:

global $hook;
$hook->module_name='modname';
$hook->module_version='modver';

function modname()
{
    return 'test module';
}

function modver()
{
    return 'v1.0.0';
}

此代码在 PHP 5.4 中完美运行。

但是我将我的 xampp 更新为 1.83,因此 PHP 更新为 5.5.3,现在我有这个错误:

Cannot redeclare modname() (previously declared in \modules\example\config.php:13) in \modules\Z48ilWd2l80cYed8\config.php on line 14

我怎么解决这个问题?

4

1 回答 1

0

It's a bad architecture. I don't understand how it works in last version. If each of modules has function modname and modver it's error must have, because in php you can't declare several function with the same name. In your case, I think that you, for example, first includes file \modules\example\config.php and than \modules\Z48ilWd2l80cYed8\config.php. Check it please and remove including \modules\example\config.php

于 2013-10-29T15:56:15.610 回答