How to add BOM to XML generated by php

Source: Internet
Author: User
Php: how to add BOMphp to generate XML? how to add BOM? because the output XML is used for flash calls, garbled characters will appear when the output xml does not contain BOM. How to add bom for requests: PHPcode $ dom = newDOMDocument (& quot; 1.0 & quot;, & quot; UTF-8 & q php: how to add BOM
How to add BOM to XML generated by php
Because the output xml is used to call flash, the output XML does not contain BOM and garbled characters will appear. How to add bom to the request:
PHP code
          $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();


------ Solution --------------------
$ Bom = pack ("C3", 239,187,191 );

Search for the landlord.
Look at the http://blog.csdn.net/cheng830306/article/details/6043303 here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.