Why Does DOM Change Encoding?

后端 未结 4 1353
你的背包
你的背包 2020-12-08 03:16
$string = file_get_contents(\'http://example.com\');

if (\'UTF-8\' === mb_detect_encoding($string)) {
    $dom = new DOMDocument();
    // hack to preserve UTF-8 ch         


        
4条回答
  •  忘掉有多难
    2020-12-08 03:39

    I had to add a utf8 header to get the correct view:

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

提交回复
热议问题