作者Clessin (Clemond)
看板PHP
标题Re: [请益] PHP 产生 RTF
时间Wed Jun 6 09:38:31 2012
※ 引述《Clessin (Clemond)》之铭言:
: Arrack大分享的方法经我测试真得是可行的方案,已顺利的将UTF-8的中文
: 取代XML档案中的变数符号,并透过browser输出WORD档给使用者,
: 且档案能顺利开启!再次感谢! 只是有个小小的疑问,为何一定要用像%1%这种
: 符号才能顺利以中文字取代掉呢?我刚试过用<<title>>这种符号,
: 反而无法取代,会让下载回来的档案都还是呈现原来<<title>>的样子....
: 不知为何?感谢!
我在w3schools.com看到了这则教学资讯,在此自问自答一下,供未来跟我遇到
同样问题的人参考:
----------------------------------------------
Entity References
Some characters have a special meaning in XML.
If you place a character like "<" inside an XML element, it will generate an
error because the parser interprets it as the start of a new element.
This will generate an XML error:
<message>if salary < 1000 then</message>
To avoid this error, replace the "<" character with an entity reference:
<message>if salary < 1000 then</message>
There are 5 predefined entity references in XML:
< < less than
> > greater than
& & ampersand
' ' apostrophe
" " quotation mark
这就是为什麽我用<<title>>的符号,无法顺利取代的原因!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.34.41.160
1F:→ MOONRAKER:括号百百种,你啥不好用,偏要用<>... 06/06 10:49
2F:→ Clessin:呵,因为原本是用rtf档来做template档,所以就用了<>符号 06/06 10:58
3F:→ MOONRAKER:对喔,rtf要避开 [ ] 06/06 11:02