PHP Loading a faraway XML error?

Source: Internet
Author: User
PHP loading remote XML error???
$yinyue =$_get[' Yinyue ']. ' $$';
if ($_get[' Geshou ']== "") {
$a = "";}
else{
$a = "$ $";}
$geshou =$_get[' Geshou '). $a;
$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 get the data I want in the remote XML locally, but I upload to the server space, there is an error??? Why is that?

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, need correct encoding
------Solution--------------------
Local and server encodings are not the same.
gb2312 and Utf-8 convert to try.
------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 on the low side.
It is best to debug locally with PHP version and settings on the server, eliminating unnecessary hassles
------Solution--------------------
discuss

$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 on the low side.
It is best to debug locally with PHP version and settings on the server ...
  • 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.