?php / / These examples are specific to using arrays inside of strings. / / When outside of a string, always quote your array string keys / / and do not use {braces} when outside of strings either. / / Let's show all errors error_reporting(E_ALL); $fruits = array('strawberry '= 'red', 'banana' = 'yellow'); / / Works but note that this works differently outside string-quotes echo "A banana is $fruits[banana] ."; / / Works echo "A banana is {$fruits['banana']} ."; / / Works but PHP looks for a constant named banana first / / as described below. echo "A banana is {$fruits[banana]} ."; / / Won't work, use braces.
Entourez le nom de la variable avec des accolades pour indiquer explicitement son nom.