file_get_html返回奇怪的符号


file_get_html returning bizarre symbols

$html = file_get_html("http://www.vegasinsider.com/mlb/odds/las-vegas/?s=316");
echo $html; 

$html作为一堆包含 vۺ (

我虽然使用:

header('Content-Type: text/html; charset=utf-8');

会有所帮助,但没有。有什么建议吗?

试试这个:

$url = 'http://www.vegasinsider.com/mlb/odds/las-vegas/?s=316';
$html = str_get_html(utf8_encode(file_get_contents($url)));
echo $html;

试试这个

$encoded = htmlentities(utf8_encode(file_get_html('yoururl')));
echo $encoded;

它会将特殊字符转换为 HTML 实体。

请在此处查看文档。

>file_get_contents有时很糟糕。将 simple_html_dom.php 中的代码更改为改用gzopen。在file_get_html()

//$contents = file_get_contents($url, $use_include_path, $context, $offset);
//get the contents of the page
$fp = gzopen($url,'r');
$contents = '';
while($html = gzread($fp , 256000))
{
    $contents .= $html;
}
gzclose($fp);