Quick Answer
json_encode() converts PHP arrays/objects into a JSON string. json_decode() parses a JSON string into PHP objects or arrays (pass true as second arg for arrays). Returns null on failure. Check json_last_error() for error details. Used heavily for API responses. JSON is the standard data format for REST APIs and config files.
Answer
json_encode() converts arrays/objects to JSON; json_decode() converts JSON strings back to PHP structures.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.
PHP interview questions and answers for beginner, junior, mid-level, senior, and expert developers. Ideal for freshers and experienced candidates preparing for PHP roles.