2013-05-08 106 views
1

我已經在我的網站一個腳本instaled之後,我有一個錯誤:不能重新聲明函數之前聲明

Fatal error: Cannot redeclare ae_detect_ie() (previously declared in /home/xdesign/public_html/Powerful/config.php:24) in /home/xdesign/public_html/Powerful/config.php on line 29 

這是該行:

function ae_detect_ie() 
{ 
    if (isset($_SERVER['HTTP_USER_AGENT']) && 
    (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) 
     return true; 
    else 
     return false; 
} 

我不明白我做錯了!

網站:http://fbswapes.com

相同的腳本的另一臺主機工作。

+0

檢查[這](http://stackoverflow.com/questions/3620659/is-it-possible-to-覆蓋函數在PHP中)和[這](http://stackoverflow.com/questions/1837184/is-it-possible-to-replace-a-function-in-php-such-as-mail並且做它一些)出來。 – BlitZ 2013-05-08 02:24:01

+1

用'包裹! function_exists()'作爲一個快速和骯髒的黑客? – alex 2013-05-08 02:27:25

+1

或者使用'include_once()'來防止加載你的配置文件兩次。 – mario 2013-05-08 02:28:55

回答

5

Simpily聲明瞭一個函數的兩倍。例:

Global.Fun.php

<?php 

     function Do_Something(){ 
     echo "This Does Something"; 
     } 
?> 

的index.php

<?php 
    include "Global.Fun.php"; 
    function Do_Something($Arg){ 
    echo "Argument Supplied".$Arg; 
    } 
?> 

通知,我已經聲明相同的功能兩次,一次在我的global.fun.php頁面中,另一次在index.php網頁..

如果您有任何疑問,一個功能是當前設置:

if (function_exists('Do_Something')){ 
    echo "Function Exists"; 
}else{ 
    echo "Function Not Found, This name Can be used!"; 
} 
+0

完成新的si工作,但我有這個錯誤: 警告:mysql_fetch_array()[function.mysql-fetch-array]:結果類型應該是MYSQL_NUM,MYSQL_ASSOC或MYSQL_BOTH。在/home/xdesign/public_html/Powerful/header.php線885 在線路885,我有: 885而($行= mysql_fetch_array($結果,$ numass)){ 886 array_push( $ got,$ row); 887} – 2013-05-08 02:43:22

+0

@CindySeoLine錯誤是..? – 2013-05-08 02:43:45

+0

警告:mysql_fetch_array()[function.mysql-fetch-array]:結果類型應該是MYSQL_NUM,MYSQL_ASSOC或MYSQL_BOTH。在885行/home/xdesign/public_html/Powerful/header.php在行885 – 2013-05-08 02:53:48