[英]JSON.parse vs json_decode
I am currently learning php as I build a database website.我目前正在学习 php,因为我正在构建一个数据库网站。 I am passing information between functions using JSON objects.
我正在使用 JSON 对象在函数之间传递信息。 I have come across two different functions JSON.parse and json_decode.
我遇到过两个不同的函数 JSON.parse 和 json_decode。 Please can someone explain to me what the difference is and when I should be using each of them.
请有人向我解释有什么区别以及我应该何时使用它们中的每一个。
Many thanks非常感谢
The language!语言!
There is no function called JSON.parse
in PHP. PHP 中没有名为
JSON.parse
函数。 Also PHP does not have this syntax at all.This is a method of Javascript. PHP 也根本没有这种语法。这是 Javascript 的一种方法。
json_decode()
is an standard function of PHP and parses JSON to PHP Objects, arrays, etc. json_decode()
是PHP 的标准函数,将 JSON 解析为 PHP 对象、数组等。
You can see PHP official documentation here for more about json_decode
您可以在此处查看 PHP 官方文档以了解有关
json_decode
更多信息
json_decode() is a php function which converts json data into php objects. json_decode() 是一个 php 函数,它将 json 数据转换为 php 对象。
json.parse() is a function in javascript which converts json data in javascript objects. json.parse() 是 javascript 中的一个函数,它将 json 数据转换为 javascript 对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.