XML error at ampersand (&)

后端 未结 5 1871
迷失自我
迷失自我 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 07:59

    public function sanitize(string $data) {
        return str_replace('&', '&', $data);
    }
    

    You are right: here is more context - the example is in relation to the ' how to deal with data containing '&' when we pass this data to SimpleXml. Of course there is also other solution to use

提交回复
热议问题