php自定义函数不能调用是怎么回事

<?php
define('IN_TG',true);
define('script','message');
require 'include/global.php';
if (!isset($_COOKIE['username'])){
alert_close('未登录');
}
if (isset($_GET['id'])){
if (!!$_row=fetch_array("SELECT tg_usename FROM project.test1 WHERE tg_id={$_GET['id']} LIMIT 1"))
{ $row=array();
$row['touser']=$_row['tg_usename'];
aleet("测试");//自定义函数 能调用
$row=_html($row);//自定义函数 显示undefind

}else {alert_close('不存在此用户');}

}else {alert('非法操作');}
//_conn();//连接数据库
require dirname(__FILE__).'/include/tittle.php';
?>
这是我在另一个文件自定义的其中两个函数 下面那个测试的可以调用 但上面的不行 有些函数也是 有些能用,有些不能用
function _html($string){
if (is_array($string)){
foreach ($string as $_key=>$_value);{
$string['key']=_html($_value);
return $string;
}
}else {
$string=htmlspecialchars($string);
}
return $string;
}
function aleet($string){
echo $string;
}
function _close(){
mysql_close
}
这个自定义函数也是无法调用

注意到你在使用_html这个自定义方法之前,只加载执行了一个文件
require 'include/global.php';
这个_html方法你是放在global.php文件中吗,如果不是,问题就是,你没有加载包含自定义函数的文件。追问

自定义函数是放在golbal的

追答

嗯,分析一下,从你的描述中得到

aleet可以使用,在这之前也没有报错,那么global.php文件没有错误;

接着使用_html方法就报错,按照你的描述是call to undefined function _html()报错是吗?

按照你的描述,我想象不到这种错误,

这样可以吗,排除其他因素的影响

<?php 
define('IN_TG',true);
define('script','message');
require 'include/global.php';
$a = array('a' => "asdfasdf", 'b' => "123asdf");
aleet("测试");
$b = _html($a);
print_r($b);

你看下还报错吗,假如还报错,可以贴出来错误,我也想看一下这种奇葩的错误

追问

Fatal error: Call to undefined function _html() in E:\php\php3\htdocs\project4\message.php on line 17
有很多之前自定义函数也会这样 有些会报错,有些不会
如果包装成类就不会这样了

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-11-03
少个分号mysql_close

mysql_close();追问

打错了 之前就有加的

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网