当前位置:Gxlcms > PHP教程 > strtr函数居然出现Catchablefatalerror_PHP教程

strtr函数居然出现Catchablefatalerror_PHP教程

时间:2021-07-01 10:21:17 帮助过:6人阅读

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...

人气教程排行