fatal error: cannot redeclare这种php问题,开发可能会碰到过,原因是很简单的,就是重复调用了相同名字的函数,看如下的实例:
<?php
function mydate($format = 'y-m-d h:i:s', $timest = 0) {
global $cfg_cli_time;
$addtime = $cfg_cli_time * 3600;
if (emptyempty($format)) {
$format = 'y-m-d h:i:s';
}
return gmdate($format, $timest + $addtime);
}
?>我们来进行包含:
require_once(dedeinc."/inc/inc_fun_funstring.php");
下面的代码也包含了一个名为mydate的函数,如果现在我们这样用就出现如 a.php
<?php
require_once (dedeinc . "/inc/inc_fun_funstring.php");
function mydate($format = 'y-m-d h:i:s', $timest = 0) {
global $cfg_cli_time;
$addtime = $cfg_cli_time * 3600;
if (emptyempty($format)) {
$format = 'y-m-d h:i:s';
}
return gmdate($format, $timest + $addtime);
}
?>就会出现fatal error: cannot redeclare mydate() (previously declared in
教程链接:
随意转载~但请保留教程地址★
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号