HTML page
<!doctypeHtml>
<Htmllang="EN" >
<Head>
<Metacharset="UTF-8" >
<title>document</Title>
</Head>
<Body>
<FormMethod= "POST" action= " weather.php "
input Span style= "COLOR: #4aa3ff" >type= "text" name= "city"/>
<input type= "submit" name=value= " query "/>
</FORM>
</BODY>
</ HTML>
HTML page does not do what style, interested in small partners can set up their own
PHP page
<?php
Header("Content-type:text/html;charset=utf-8");
//Determine if the user submits data is legitimate
If(Isset($_post[' Submit '])){
//The receiving table only son over.CityData
$city =$_post[' City '];
//Convert character encoding,Mb_convert_ecoding ("The data to be transferred","The character encoding to turn into","From what code to turn into")
$city =Mb_convert_encoding($city,' GBK ',' Utf-8 ');
//PutCityConvert to input to address barUrlof data
$city =UrlEncode($city);
//Get the interface address, find a website to see the address of the weather page
$url ="Http://php.weather.sina.com.cn/xml.php?city={$city}&password=djoyniet8234jlsk&day=0 ";
//Send Browser request
$str =File_get_contents($url);
//GeneratedXmlobject, note that it is in the form of a string
$xml =Simplexml_load_string($str);
//For relevant information,
Echo"City:".$xmlWeather->City;
Echo"<br/>";
Echo"Weather conditions:". $xml-weather->status1;
echo "<br/>";
echo " dressing advice :". $xml-weather->chy_shuoming;
}< /c2>
Simple use of XML in conjunction with PHP to create a weather query form