File_get_contents: use ini_set ('User _ agent', 'mozilla/4.0 & nbsp; (compatible; & nbsp; MSIE & nbsp; 6.0; & nbsp; windows & nbsp; NT & nbsp; 5.1) '); & nbsp; // & nbsp; This file_get_contents has a strange problem in obtaining XML.
Use
Ini_set ('User _ agent', 'mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) '); // the result of this addition is the same.
$ Contents = file_get_contents ($ url );
Obtain an XML file. The result is:
2421 Shanghai
2420 Tianjin
The source code I obtained using a browser or other tools is as follows:
2421 Juan Miao
2420 Trigger
Why? One is cityid, the other is id, the other is cityname, and the other is name
------ Solution --------------------
What is your url .. You can paste it out.
------ Solution --------------------
2421 Shanghai
2420 Tianjin
2419 Beijing
2418 Chongqing
372 Shenzhen
2422 Guangzhou
.....
------ Solution --------------------
The browser or file_get_contents both have the following results:
2421
Shanghai
2420
Tianjin
2419
Beijing
2418
Chongqing
...........................
------ Solution --------------------
The author's browser encoding problem