PHP has 4 built in JSON functions called
json_encode() & json_decode() : This function are used for encoding and decoding in JSON format.
json_last_error_msg() & json_last_error() : This function are use full after json_encode() or json_decode() call. json_last_error_msg() function returns the error string , json_last_error() Returns an integer which can be found in the PHP Manual. for no error checking we can compare with JSON_ERROR_NONE constant.
Check for valid JSON
we can use json_last_error() PHP function to check validity of JSON, It returns JSON_ERROR_NONE predefined constant value if JSON successfully decoded or encoded by PHP’s josn functions.
How to use is_json function:
That’s all for today I hope you like this tutorial please don’t forget to give me your feedback.
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.