Home » php » Using JSON inside PHP
08 February 2017
Using JSON inside PHP
JSON (JavaScript Object Notation) allows to pass data between server and web application similar to XML .
PHP: Hypertext Preprocessor , is ueed for creating dynamic web pages. It can be used inside HTML as input and the output can be in HTML too.
PHP has two functions to handle JSON objects.
1) json_decode( )
It takes a JSON encoded string input , and returns into PHP variable
2) json_encode( )
It takes PHP variable and return JSON representation of the value
There is another function useful in case of debugging :
json_last_error()
It returns the last error due to recent JSON parsing.
Example #1 (php code) use of json_encode()
Output:
Example #2 (php code) using json_decode()
Output :
Other Recommended Posts on php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment