When you want to pass data from php to javascript or javascript to php then we use JSON.
JSON Enviorment:-
As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default.
JSON Functions:-
(i) json_encode:- Returns the JSON representation of a value.
(ii) json_decode:- Decodes a JSON string.
(iii) json_last_error_msg:- Returns the error string of the last json_encode() or json_decode() call.
(iv) json_last_error:- Returns the last error occurred.