【发布时间】:2010-10-06 12:31:30
【问题描述】:
我使用 curl 获取带有俄语的 utf-8 页面。如果我回显文本,则显示良好。然后我使用这样的代码
$dom = new domDocument;
/*** load the html into the object ***/
@$dom->loadHTML($html);
/*** discard white space ***/
$dom->preserveWhiteSpace = false;
/*** the table by its tag name ***/
$tables = $dom->getElementsByTagName('table');
/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName('tr');
/*** loop over the table rows ***/
for ($i = 0; $i <= 5; $i++)
{
/*** get each column by tag name ***/
$cols = $rows->item($i)->getElementsByTagName('td');
echo $cols->item(2)->nodeValue;
echo '<hr />';
}
$html 包含俄语文本。在 echo $cols->item(2)->nodeValue; 行之后显示错误文本,而不是俄语。我尝试 iconv 但不起作用。有什么想法吗?
【问题讨论】:
-
我不明白你的问题是什么。你得到什么错误文本? “不工作”是什么意思?
-
而不是俄语,我得到 Ð ÑоÑо?
标签: php curl encoding domdocument iconv