Re: [請益] PHP 產生 RTF
※ 引述《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
→
06/06 10:49, , 1F
06/06 10:49, 1F
→
06/06 10:58, , 2F
06/06 10:58, 2F
→
06/06 11:02, , 3F
06/06 11:02, 3F
討論串 (同標題文章)