Re: [請益] PHP 產生 RTF

看板PHP作者 (Clemond)時間12年前 (2012/06/06 09:38), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串12/12 (看更多)
※ 引述《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 &lt; 1000 then</message> There are 5 predefined entity references in XML: &lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " 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
呵,因為原本是用rtf檔來做template檔,所以就用了<>符號
06/06 10:58, 2F

06/06 11:02, , 3F
對喔,rtf要避開 [ ]
06/06 11:02, 3F
文章代碼(AID): #1FphIPQI (PHP)
討論串 (同標題文章)
文章代碼(AID): #1FphIPQI (PHP)