我現在建立的是我從中文RSS網站的RSS feed中抓取的,但是一旦我回應出來是空白的,我的代碼就工作在英文RSS上,我嘗試了很多解碼,iconv,header(「Content-Type:text/html; charset = utf-8「);,但仍然不能在我的屏幕上顯示任何中文單詞。在php中如何顯示漢字?
這裏是我的編碼:
header("Content-Type: text/html; charset=utf-8");
function getrssfeed($feed_url){
$Current = date("Y-m-d" ,strtotime("now"));
$content = file_get_contents($feed_url);
$xml = new SimpleXmlElement($content);
$body = "";
foreach($xml->channel->item as $entry){
$body .= get_html_translation_table(htmlspecialchars_decode(strip_tags($Current ." ". $entry->description))) . "\n\n";
//$result = iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $body);
$i++;
if($i==5) {
break;
}
}
echo $body;
}
getrssFeed( 「http://news.baidu.com/n?cmd=1 &類= enternews & TN = RSS」);
你能幫我解決我的問題嗎?
謝謝
你甚至不喜歡??????????問題標記 –
不,我只是空白頁 – user941885
這可能有助於http://stackoverflow.com/questions/2899274/php-simplexml-why-does-simplexml-load-string-fail-to-parse-google-weather- – skyuzo