Let me take a look at this code. how is it garbled after running? Let me take a look at this code. how is it garbled after running? & Lt ;? Phpfunction & nbsp; my_headlines ($ url) & nbsp ;{& nbsp; & nbsp; $ rdf & nbsp; parse_url ($ url ); & nbs help me check this code. how is it garbled after running?
Let me take a look at this code. how is it garbled after running?
Function my_headlines ($ url ){
$ Rdf = parse_url ($ url );
$ Fp = fsockopen ($ rdf [host], 80, $ errno, $ errstr, 15 );
If (! $ Fp ){
$ Content = "Problema! ";
Return;
}
If ($ fp ){
Fputs ($ fp, "GET". $ rdf [path]. "? ". $ Rdf [query]." HTTP/1.0 \ r \ n ");
Fputs ($ fp, "HOST:". $ rdf [host]. "\ r \ n ");
$ String = "";
While (! Feof ($ fp )){
$ Pagetext = fgets ($ fp, 300 );
$ String. = chop ($ pagetext );
}
Fputs ($ fp, "Connection: close \ r \ n ");
Fclose ($ fp );
$ Items = explode ("", $ String );
For ($ I = 0; $ I <10; $ I ++ ){
$ Link = ereg_replace (".* "," ", $ Items [$ I]);
$ Link = ereg_replace (". * "," ", $ Link );
$ Title2 = ereg_replace (".* "," ", $ Items [$ I]); <br/> $ title2 = ereg_replace (". * "," ", $ Title2 );
If ($ items [$ I] = ""){
$ Content = "";
Return;
} Else {
If (strcmp ($ link, $ title )){
$ Cont = 1;
$ Content. ="
$ Title2\ R \ n ";
}
}
}
}
Echo "$ content ";
}
My_headlines ("http://news.sohu.com/rss/it.xml ");
?>
------ Solution --------------------
Declare the language type: UTF-8
------ Solution --------------------