您好,欢迎访问一九零五行业门户网

strtr 函数居然出现 Catchable fatal error_PHP教程

strtr 函数居然出现 catchable fatal error
错误提示:
catchable fatal error: object of class variant could not be converted to string in d:wwwphpnowhtdocsxmlincxmlclass.php on line 160
160行代码: return $tab1.strtr($content,array('>'=>''>','&'=>'&',''=>'','=>'''));
复制代码160行周围代码 function encode($content,$type='element',$tab1='',$br='') { if($type=='element') { return $tab1.strtr($content,array('>'=>''>','&'=>'&',''=>'','=>''')); }elseif($type=='cdata') { return '',']] >',$content).$br.']]>'; } }
复制代码重来没遇到过。
我记忆中只有php+access读取时会出现这样的问题。
在网上搜索了2小时,中文 英文全找了。没找到一点蛛丝马迹
类的全部代码见:
[url=http://www.souzz.net/html/edu/php/php8/6590.html]链接标记http://www.souzz.net/html/edu/php/php8/6590.html[/url]
[ ]
我来回答
d8888d回贴内容-------------------------------------------------------
$content这个是个类.不是字符串吧
d8888d回贴内容-------------------------------------------------------
原帖由 tankme 于 2009-3-5 22:26 发表 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=894659&ptid=107280]链接标记[img]http://bbs.111cn.cn/images/common/back.gif[/img][/url]
$content这个是个类.不是字符串吧
能再具体点吗?没听明白
d8888d回贴内容-------------------------------------------------------
看错误提示就已经很明白了,在php5中不能直接将对象输出为字符串,如果要实现这样的功能需要在对象的基类当中实现__tostring()方法.
也就是说在楼主的代码中$content就是这样的一个对象
http://www.bkjia.com/phpjc/632555.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/632555.htmltecharticlestrtr 函数居然出现 catchable fatal error 错误提示: catchable fatal error: object of class variant could not be converted to string in d:wwwphpnowhtdocsxmlincxmlclass.ph...
其它类似信息

推荐信息