PHP - File Handling
Identify the error in this PHP code snippet:
$json = '{"fruit":"apple","count":3}';
$data = json_decode($json, true);
echo $data->fruit;$json = '{"fruit":"apple","count":3}';
$data = json_decode($json, true);
echo $data->fruit;true makes json_decode return an associative array.$data->fruit tries to access an object property, but $data is an array, so this causes an error.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions