php 生成xml添加BOM

  • Post author:
  • Post category:php


前两天做公司网站的CMS,因为xml的问题郁闷了好几天,明明是utf-8的xml,可是前台的flash却总是在读取中文xml时出现乱码。

找了几天原来要在写xml文件时添加BOM信息。代码如下:

下载:


adddom.php



  1. <?php

  2. $bom


    =


    pack


    (





    C3





    ,


    239


    ,


    187


    ,


    191


    )


    ;

  3. $xml


    =


    $bom


    ;



  4. $xml


    .=











    ;

  5. file_put_contents


    (


    $filename


    ,


    $xml


    )


    ;

  6. ?>



版权声明:本文为cheng830306原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。