In this tutorial of php code for beginners we will look at what is json and how json encode and json decode work with example.
What is JSON:-
Json encode is used for encoding the data that contain string, numbers etc. json_encode return the value that is recognized by JSON. On other hand we use json_decode to decode this json representational value and use in our code.
Json decode is used for decoding the value send by the json_encode.
Json process is divided in to two parts:
In first part we create json data using php array and encode this with json_encode.
In second part we receive the the json encoded data and decode this with help of json_decode and will use that data in our php code.
echo $object->php; //It will show 3
Hope this php tutorial is useful for you. Keep following www.phpcodeforbeginner.blogspot.in for more help.