>  기사  >  백엔드 개발  >  strtr 函数居然出现 Catchable fatal error_PHP教程

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

WBOY
WBOY원래의
2016-07-13 10:51:291950검색




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就是这样的一个对象


www.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...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.