在PHP中是否有像json_encode()这样的xml_encode()? [英] Is there an xml_encode() like json_encode() in PHP?

查看:101
本文介绍了在PHP中是否有像json_encode()这样的xml_encode()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,使用json_encode()可以很容易地传回json对象.
但是,是否有与之等效的XML?

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

推荐答案

JSON可以本地表示php数组,整数,字符串等. XML没有这样的概念,只有元素,属性和文本.如果要逐字转移对象,请使用JSON.如果要实现复杂的API,请使用XML,例如php DOM接口.

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.

这篇关于在PHP中是否有像json_encode()这样的xml_encode()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆