Home > Backend Development > PHP Tutorial > file_get_contents获取XML的奇怪有关问题

file_get_contents获取XML的奇怪有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:12:42
Original
1326 people have browsed it

file_get_contents获取XML的奇怪问题

ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); // 这一句加不加结果都一样
$contents=file_get_contents($url);
获取一个XML文件,得到的结果是:


2421上海
2420天津


而我用浏览器或其他工具取得的源码都是这样的:


2421涓婃捣
2420澶╂触


为什么会这样呢? 一个是cityid,另一个是id,一个是cityname,另一个是name


------解决方案--------------------
你的url是什么。。可以贴出来吧。
------解决方案--------------------

2421上海
2420天津
2419北京
2418重庆
372深圳
2422广州
.....


------解决方案--------------------
浏览器或file_get_contents都是如下结果
<br /><?xml version="1.0" encoding="UTF-8"?><cities><br /><city><cityid>2421</cityid><cityname>上海</cityname></city><br /><city><cityid>2420</cityid><cityname>天津</cityname></city><br /><city><cityid>2419</cityid><cityname>北京</cityname></city><br /><city><cityid>2418</cityid><cityname>重庆</cityname></city><br />...........................<br />
Copy after login

------解决方案--------------------
楼主浏览器编码问题
Related labels:
gt lt
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template