JSON اسئلة واجوبة المقابلات
Question: Explain JSON with php.Answer: Json is too much easy with php There is no installation needed to use these functions; they are part of the PHP core. nothing more need to know just only use { ,[ and create json format string and use three php function json_encode() to get JSON representation of a value, json_decode() for Decodes a JSON string, json_last_error() to get the last error occurred in process.Example: $string='{ "firstName": "Rohit", "lastName": "Singh", "age": 26, "address": { "streetAddress": "Mira Road Thane ", "city": "Mumbai", "state": "maharshtra", "postalCode": "401107" }, "phoneNumber": [ { "type": "home", "number": "022 333-1234" }, { "type": "fax", "number": "022 444-4567" } ] }'; $decodeString = json_decode($string); echo 'First Name - '.$decode->{"firstName"}; echo 'Last Name - '.$decode->{"lastName"}; echo 'Address - '.$decode->{"address"}->{"streetAddress"}; Out put : Print below First Name - Rohit Last Name - Singh Address - Mira Road Thane |
احفظ للمراجعة
احفظ هذا العنصر في الإشارات المرجعية، او حدده كصعب، او ضعه في مجموعة مراجعة.
سجل الدخول لحفظ الإشارات المرجعية والاسئلة الصعبة ومجموعات المراجعة.
هل هذا مفيد؟ نعم لا
الاكثر فائدة حسب تقييم المستخدمين:
- Who is the Father of JSON ?
- What is the file extension of JSON?
- What is JSON?
- Why use JSON over XML?
- Explain JSON with php.