XML error at ampersand (&)

后端 未结 5 1874
迷失自我
迷失自我 2020-11-29 07:29

I have a php file which prints an xml based on a MySql db.

I get an error every time at exactly the point where there is an & sign.

Here

5条回答
  •  旧巷少年郎
    2020-11-29 08:13

    $string = htmlspecialchars($string,ENT_XML1);

    is the most universal way to solve all encoding errors (IMHO better that write custom functions + there is no point to solve just &).

    Credit: Put Wrikken's and joshweir's comment as answer to be more visible.

提交回复
热议问题