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);