PHP DOMDocument loadHTML not encoding UTF-8 correctly

后端 未结 13 1715
梦如初夏
梦如初夏 2020-11-22 15:11

I\'m trying to parse some HTML using DOMDocument, but when I do, I suddenly lose my encoding (at least that is how it appears to me).

$profile = \"

        
13条回答
  •  [愿得一人]
    2020-11-22 15:34

    Works finde for me:

    $dom = new \DOMDocument;
    $dom->loadHTML(utf8_decode($html));
    ...
    return  utf8_encode( $dom->saveHTML());
    

提交回复
热议问题