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