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
- Write HTML in PHP
- List of PHP ODBC functions
- Write PHP code inside HTML file
- Short Note on Types of Array in PHP
- How to Replace space with Dash in PHP
- php File Upload - Tutorial with Example
- How to decode JSON using PHP5 for Facebook application
- Get ip address using PHP
- Using JSON inside PHP
- PHP $$variable Double dollar sign Meaning
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment