2013-05-08 109 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