2014-09-28 48 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

相關問題