2014-09-28 123 views
-3

这是为什么给出这个错误 错误是 致命错误:不能重新声明anp_realip()(在cr.php先前声明:196)在在文件cr.php线219 E_COMPILE_ERROR错误cr.php在行219:不能重新声明anp_realip()(在cr.php先前声明:196)致命错误:不能重新声明anp_realip()(以前在E_COMPILE_ERROR错误在文件中声明

线196 $的IP = FALSE; 线219功能(最后一个)的结束}

function anp_realip() 
{ 
    // No IP found (will be overwritten by for 
    // if any IP is found behind a firewall) 
    $ip = FALSE; 

    // User is behind a proxy and check that we discard RFC1918 IP addresses 
    // if they are behind a proxy then only figure out which IP belongs to the 
    // user. Might not need any more hackin if there is a squid reverse proxy 
    // infront of apache. 
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 

     // Put the IP's into an array which we shall work with shortly. 
     $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']); 

     for ($i = 0; $i < count($ips); $i++) { 
      // Skip RFC 1918 IP's 10.0.0.0/8, 172.16.0.0/12 and 
      // 192.168.0.0/16 
      // below. 
      if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i])) { 
       $ip = $ips[$i]; 
       break; 
      } 
     } 
    } 
    // Return with the found IP or the remote address 
    return ($ip ? $ip : $_SERVER['REMOTE_ADDR']); 
} 

好吧,所以调试设置为2我得到这个我的电脑:

用户不在例外列表中 没有为当前访问者保存国家代码(_DEBUG_MODE = 1禁止发送cookie); cookie名称:anp_810c087185 访问者的国家和地区代码从COOKIE/SESSION加载:'none' 从文本中获取全文:'IT' 查找国家'IT'的URL 致命错误:无法重新声明anp_realip()在第219行的cr.php中声明E_COMPILE_ERROR在第219行的文件 cr.php中的错误:无法重新声明anp_realip()(先前在cr.php中声明:196)

我的另一台计算机得到此:

用户不在例外列表中 没有国家代码保存为当前访问者(_DEBUG_MODE = 1防止发送cookie); cookie名称:此访客anp_810c087185 国家代码是从COOKIE/SESSION负载:“无” 葛亭国家从文本中全:“NL” 找到适合全国NL“ 参观者的URL现在应该重定向到http://www.test.com

那怎么样,为什么这不是为我工作,但它为他呢?试图清除浏览器捕获,没有运气。你能帮我吗?

+0

你有一个叫做cr.php的文件吗? – 2014-09-28 00:52:20

+0

是的,该函数位于该文件中,您希望我粘贴该文件中的所有代码? – Dan 2014-09-28 01:06:45

+0

如上所述检查行219和196 – 2014-09-28 01:08:55

回答

1

这有时会发生在您requireinclude两次相同的文件中。切换到require_once和/或include_once(这些只需要/包括一个文件,如果它尚未被要求/包括)。

这可能是你加载这个文件两次,第二次加载时,PHP抱怨说这个函数已经被定义了。

+0

我知道并理解,但包含两次?错误是为$ ip = false;那怎么能包括两次? – Dan 2014-09-28 09:10:07

+0

是的,cr.php被包含了两次,我没有看到,非常感谢。 – Dan 2014-09-28 22:54:16

相关问题