error message while parsing JSON

I seem to be getting this error message for this script. Does anyone know how I can fix it? Notice that the code works because the word “love” appears at the end of the error message. I just need to figure out how to get rid of the error…

This is the code:

$json=’{“emotion”:“love”}’;

$json_a=json_decode($json,true);

echo $json_a[emotion];
?>

This is the output:

Notice: Use of undefined constant emotion - assumed ‘emotion’ in /Users/my_computer/Sites/widget_corp/content_test4.php on line 15 love

I think you forgot the single quotes in the line :

echo $json_a[emotion]; => echo $json_a[‘emotion’];

Cheers :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service