Cannot redeclare a function previously declared [duplicate]

≯℡__Kan透↙ 提交于 2019-12-10 22:04:18

问题


After I have instaled in my site one script, I have an error:

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

This is the line:

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

I don't understand what I did wrong!

The site: http://fbswapes.com

The same script is working in another host.


回答1:


Simpily you have declared a function twice.. Example:

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;
   }
?>

Notice, I have declared the same function twice, one in my global.fun.php page and again in the index.php page..

If you are in doubt that a function is currently set:

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


来源:https://stackoverflow.com/questions/16431652/cannot-redeclare-a-function-previously-declared

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!