php 无法重新声明先前声明的函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16431652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:07:19  来源:igfitidea点击:

Cannot redeclare a function previously declared

phpmysqlfunctionredeclare

提问by Cindy SeoLine

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

网站:http: //fbswapes.com

The same script is working in another host.

相同的脚本在另一台主机上运行。

回答by Daryl Gill

Simpily you have declared a function twice.. Example:

简单地说,您已经两次声明了一个函数。例如:

Global.Fun.php

Global.Fun.php

<?php

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

Index.php

索引.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.phppage and again in the index.phppage..

请注意,我已经两次声明了相同的函数,一次在我的global.fun.php页面中,一次在index.php页面中。

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!";
}