An error occurred while loading remote XML in PHP ??? & Lt ;? Php $ yinyue $ _ GET [yinyue]. $; if ($ _ GET [geshou] & quot;) {$ a & quot; & quot ;;} else {$ a & quot; $ & quot; ;}$ geshou $ _ GET [geshou]. $ a; $ An error occurred while loading remote XML in musicbox PHP ???
$ Yinyue = $ _ GET ['Y']. '$ ';
If ($ _ GET ['geshou'] = ""){
$ A = "";}
Else {
$ A = "$ ";}
$ Geshou = $ _ GET ['geshou']. $;
$ Music = 'http: // box.zhangmen.baidu.com/x? Op = 12 & count = 1 & title = '. $ yinyue. $ geshou;
?>
// Set name of XML file
$ File = "$ music ";
// Load file
$ Xml = simplexml_load_file ($ file) or die ("Unable to load XML file! ");
For ($ I = 0; $ I Url); $ I ++)
{
$ A = $ xml-> url [$ I]-> encode;
$ B = $ xml-> url [$ I]-> decode;
$ C = substr ($ a, 0, strrpos ($ a, '/') + 1 );
$ Result = trim ($ c). trim ($ B );
Echo $ result .'
';
}
?>
I can obtain the data I want from remote xml locally, but an error occurs when I upload the data to the server space ??? Why?
Warning: simplexml_load_file () [function. simplexml-load-file]: http://box.zhangmen.baidu.com/x? Op = 12 & count = 1 & title = % E9 % 85% B7 % E7 % 88% B1 % 24% 24: 1: parser error: switching encoding: encoder error in/home/xintutuc/public_html/y/music. php on line 22
------ Solution --------------------
Some characters may be garbled and must be correctly encoded.
------ Solution --------------------
The local and server encoding is different.
Convert gb2312 and UTF-8.
------ Solution --------------------
$ S = str_replace ('Encoding = "gb2312" ', 'Encoding = "UTF-8"', file_get_contents ($ file ));
$ Xml = simplexml_load_string ($ s) or die ("Unable to load XML file! ");
The php version on your server is low.
It is best to use the same php version and settings on the server during local debugging to save unnecessary trouble.
------ Solution --------------------
Discussion
$ S = str_replace ('Encoding = "gb2312" ', 'Encoding = "UTF-8"', file_get_contents ($ file ));
$ Xml = simplexml_load_string ($ s) or die ("Unable to load XML file! ");
The php version on your server is low.
It is best to use the php version and settings on the server during local debugging ......