PHP generates XML file format related issues

Source: Internet
Author: User
PHP generates XML file format problems
Can we ask Daniel PHP to make the resulting XML file format dead to the UNIX utf-8 format?
Why do I generate the PC ANSI format every time?
On the code: please Daniel help me to see how to change can make the file format is UNIX utf-8 format, thank you eldest sister help:
PHP Code
  
   
  
   
  
   
    
   blah
  
    eof;//if (file_put_contents ("F:/over.xml", $str)) {//    echo "Yesyesyes";/} else {//    echo "Nononon",//} $DH = fopen ("F:/over.xml", "W"), $dh 2 = fwrite ($DH, $STR); fclose ($DH);? >


The generated file is opened with EditPlus in PC ANSI format I want to generate a format that is UNIX utf-8 good news


------Solution--------------------
Then your PHP program file to be saved in UNIX utf-8 format
------Solution--------------------
Your program file is utf-8.
Just write $dh 2 = fwrite ($DH, "\XEF\XBB\XBF". $str); You can do it.

If it's GBK, you need to transcode it.
$str = Iconv (' GBK ', ' utf-8 ', $str);

To fully conform to UNIX format, you also need to remove the ' carriage return ' character
$str = Preg_replach ("/[\r\n]+/s", "\ n", $str);
  • Related Article

    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.