Reputation: 4833
I am currently learning php as I build a database website. I am passing information between functions using JSON objects. I have come across two different functions JSON.parse and json_decode. Please can someone explain to me what the difference is and when I should be using each of them.
Many thanks
Upvotes: 2
Views: 3929
Reputation: 6994
The language!
There is no function called JSON.parse
in PHP. Also PHP does not have this syntax at all.This is a method of Javascript.
json_decode()
is an standard function of PHP and parses JSON to PHP Objects, arrays, etc.
You can see PHP official documentation here for more about json_decode
Upvotes: 9
Reputation: 592
json_decode() is a php function which converts json data into php objects.
json.parse() is a function in javascript which converts json data in javascript objects.
Upvotes: 1