Home > Backend Development > PHP Tutorial > php生成XML怎么加BOM

php生成XML怎么加BOM

WBOY
Release: 2016-06-13 10:15:00
Original
1001 people have browsed it

php生成XML如何加BOM
php生成XML如何加BOM
由于输出的xml用于给flash调用的,现在输出的XML不带BOM的,会出现乱码。请求怎么加bom上去:

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->        $dom = new DOMDocument("1.0","utf-8");         header("Content-Type: text/html; charset=unicode");        //items        $root = $dom->createElement("items");         $dom->appendChild($root);         //count        $count = $dom->createAttribute("count");         $root->appendChild($count);         $count_value = $dom->createTextNode("6");         $count->appendChild($count_value);                 //item        $item = $dom->createElement("item");         $root->appendChild($item);         $text = $dom->createTextNode($content);        $item->appendChild($text);         //id                $id = $dom->createAttribute("id");         $item->appendChild($id);         $idValue = $dom->createTextNode("156");         $id->appendChild($idValue);         //title        $title = $dom->createAttribute("title");         $item->appendChild($title);         $titleValue = $dom->createTextNode("test");         $title->appendChild($titleValue);         $content=$dom->saveXML();
Copy after login


------解决方案--------------------
$bom = pack("C3",239,187,191);

帮楼主搜索了哈
看看这里http://blog.csdn.net/cheng830306/article/details/6043303
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template