PHP Display Special Characters

后端 未结 2 1774
故里飘歌
故里飘歌 2020-12-11 21:20

When i output the text £3.99 per M² from an xml file,browser displays it as £3.99 per M².XML file is in UTF-8 format.I wonder how to fix

2条回答
  •  遥遥无期
    2020-12-11 21:47

    You should encode html entities:

    you could try

    htmlentities($str, ENT_QUOTES, "UTF-8");
    

    Look here for a complete reference

    If you still have problems sometimes you also have to decode the string with utf8_decode() so you can try:

    $str = utf8_decode($str);
    $str = htmlentities($str, ENT_QUOTES);
    

提交回复
热议问题