本文介绍了无法重新声明先前声明的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
致命错误:无法重新声明ae_detect_ie()在我的站点中安装了一个脚本之后, (之前在/home/xdesign/public_html/Powerful/config.php:24中声明)在/home/xdesign/public_html/Powerful/config.php在第29行
$ b $ p
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b {
if(isset($ _ SERVER ['HTTP_USER_AGENT'])&&
(strpos($ _ SERVER ['HTTP_USER_AGENT'],'MSIE')!== false))
返回true;
else
返回false;
}
我不明白我做错了什么!
网站: p>
同一个脚本在另一个主机上工作。
解决方案
例如:
Global.Fun.php
<?php
函数Do_Something(){
echoThis Does Something;
}
?>
Index.php
<?php
包含Global.Fun.php;
函数Do_Something($ Arg){
echo提供的参数。$ Arg;
}
?>
注意,我已经声明了两次相同的函数,一个在我的 global中。 fun.php
页面,并再次在 index.php
页面中显示。
如果你不确定当前是否设置了一个函数:
if(function_exists('Do_Something')){
echo 功能存在;
} else {
echoFunction Not Found,This name can be used!;
}
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.
解决方案
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!";
}
这篇关于无法重新声明先前声明的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!