【www.gdgbn.com--常见问题】

fatal error: cannot redeclare这种问题php教程 开发可能会碰到过,原因是很简单的,就是重复调用了相同名字的函数,

function mydate($format="y-m-d h:i:s",$timest=0)
{
 global $cfg_cli_time;
 $addtime = $cfg_cli_time * 3600;
 if(empty($format))
 {
  $format = "y-m-d h:i:s";
 }
 return gmdate ($format,$timest+$addtime);
}

面我的

require_once(dedeinc."/inc/inc_fun_funstring.php");


也包含了一个名为mydate的函数如果现在我们这样用就出现如

a.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(empty($format))
 {
  $format = "y-m-d h:i:s";
 }
 return gmdate ($format,$timest+$addtime);
}

就会出现fatal error: cannot redeclare mydate() (previously declared in

本文来源:http://www.gdgbn.com/jiaocheng/29957/