我試圖從yahoo.com獲取搜索結果。file_get_contents()將UTF-8轉換爲ISO-8859-1
但是 file_get_contents()將UTF-8字符集(yahoo使用的charset)內容轉換爲ISO-8859-1。
嘗試:
$filename = "http://search.yahoo.com/search;_ylt=A0oG7lpgGp9NTSYAiQBXNyoA?p=naj%C5%A1%C5%A5astnej%C5%A1%C3%AD&fr2=sb-top&fr=yfp-t-701&type_param=&rd=pref";
echo file_get_contents($filename);
腳本作爲
header('Content-Type: text/html; charset=UTF-8');
或
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
或
$er = mb_convert_encoding($filename , 'UTF-8');
或
$s2 = iconv("ISO-8859-1","UTF-8",$filename);
或
echo utf8_encode(file_get_contents($filename));
沒有幫助,因爲讓網頁內容speciall字符式T z是用問號代替後???
我將不勝感激任何形式的幫助。
** file_get_contents()不會轉換任何內容** – 2011-04-09 11:35:32