Php 文件_get_contents()不';不能返回正确的内容

Php 文件_get_contents()不';不能返回正确的内容,php,character-encoding,file-get-contents,Php,Character Encoding,File Get Contents,我使用了以下源代码(文件编码:不带BOM的UTF-8): 文件\u get\u contents()如何返回� 而不是文件顶部的一个ñ?ini\u集('default\u charset','utf-8')�.字符集是为什么定义的?如果不是utf-8,那么您也需要将其转换为utf-8;你可能会得到一个重复的blockFireBug,它说它的字符集是UTF-8。问题是特殊字符不是用实体写的。 <?php $contents = file_get_contents('http://www.e

我使用了以下源代码(文件编码:不带BOM的UTF-8):


文件\u get\u contents()如何返回� 而不是文件顶部的一个ñ?

ini\u集('default\u charset','utf-8')
�.字符集是为什么定义的?如果不是utf-8,那么您也需要将其转换为utf-8;你可能会得到一个重复的blockFireBug,它说它的字符集是UTF-8。问题是特殊字符不是用实体写的。
<?php

$contents = file_get_contents('http://www.example.com');

?>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    </head>
    <body>
        <?= $contents; ?>
    </body>
</html>
var_dump(file_get_contents('http://www.example.com'));