PHP AdvancedLesson 41Free preview
PHP JSON
This lesson is part of PHP · All levels
Summary
JSON is a lightweight, easy-to-understand text-based data exchange format for humans and machines. PHP provides json_encode() to convert array/object to JSON string and json_decode() to convert it back. This format is very commonly used in modern web API communication.
Key points
- Json_encode() converting PHP array/object to JSON string
- Json_decode() converts JSON strings into arrays or PHP objects
- JSON supports objects {} and arrays [] as data structures
- Always check the decoding success because the external data may be invalid.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.