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

后端 未结 5 895
天涯浪人
天涯浪人 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:27

    JSON can express php arrays, integers, strings, etc. natively. XML has no such concepts - just elements, attributes, and text. If you want to transfer an object verbatim, use JSON. If you want to implement a complex API, use XML, for example the php DOM interface.

提交回复
热议问题