您好,欢迎访问一九零五行业门户网

php如何实现json转字符串

在php中可以使用json_decode函数实现json转字符串,该函数的作用就是对json格式的字符串进行解码,其使用语法是“json_decode ( string $json [, bool $assoc...]) ”。
推荐:《php视频教程》
json_decode — 对 json 格式的字符串进行解码
说明 
json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] ) : mixed
接受一个 json 编码的字符串并且把它转换为 php 变量
参数 
json
待解码的 json string 格式的字符串。
这个函数仅能处理 utf-8 编码的数据。
note:
php 实现了 json 的一个超集,参考 » rfc 7159.
assoc
当该参数为 true 时,将返回 array 而非 object 。
depth
指定递归深度。
options
由 json_bigint_as_string, json_invalid_utf8_ignore, json_invalid_utf8_substitute, json_object_as_array, json_throw_on_error 组成的掩码。 这些常量的行为在json constants页面有进一步描述。
返回值 
通过恰当的 php 类型返回在 json 中编码的数据。值true, false 和 null 会相应地返回 true, false 和 null。 如果 json 无法被解码, 或者编码数据深度超过了递归限制的话,将会返回null 。
以上就是php如何实现json转字符串的详细内容。
其它类似信息

推荐信息