2

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

2
  • 1
    PHP doesn't have a function called JSON.parse, but javascript does. Commented Jun 29, 2013 at 16:18
  • Ahhh...that's where Im getting confused. Yes I have used a few bits of javascript. Thanks! Commented Jun 29, 2013 at 16:20

2 Answers 2

9

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.