note 16725 deleted from language.types.string by jimw

From: Date: Sat, 10 Nov 2001 23:40:10 +0000
Subject: note 16725 deleted from language.types.string by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20724@lists.php.net to get a copy of this message
There is a funny thing... I had something like this: $a = array("lala" => 10, "zuzu" => 20); define('KUKU', 'lala'); //name of a key in the array And I tried to print some value of the array: echo KUKU." is $a[KUKU]"; And php didn't print the value, just: lala is It was a big problem until I understood that it was the same as if I wrote: echo KUKU." is ".$a["KUKU"]; Don't forget about that. The right ways to do it were: echo KUKU." is ".$a[KUKU]; //ouput: lala is 10 //or echo KUKU." is ${a[KUKU]}"; //ouput: lala is 10 //or echo KUKU." is {$a[KUKU]}"; //ouput: lala is 10 //but not echo KUKU." is $a{[KUKU]}"; //ouput: Array{[KUKU]} //and not echo KUKU." is $a[{KUKU}]"; //ouput: Parse error . . . I think the first one is the most evident and the best for reading.

« previous php.notes (#20724) next »