Is there an xml_encode() like json_encode() in PHP?

后端 未结 5 905
天涯浪人
天涯浪人 2020-12-16 11:53

In PHP it is easy to pass back an json objects by using the json_encode().
However is there an XML equivalent of this?

5条回答
  •  眼角桃花
    2020-12-16 12:25

    This works for me in most cases:

    $str = htmlentities($str , ENT_XML1);
    

    Docs: http://php.net/manual/en/function.htmlentities.php

提交回复
热议问题