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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.