PHP DOMDocument loadHTML not encoding UTF-8 correctly

后端 未结 13 1531
梦如初夏
梦如初夏 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:24

    You could prefix a line enforcing utf-8 encoding, like this:

    @$doc->loadHTML('' . "\n" . $profile);
    

    And you can then continue with the code you already have, like:

    $doc->saveXML()
    

提交回复
热议问题