strtr 函數居然出現 Catchable fatal error_PHP教程

來源:互聯網
上載者:User
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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.