note 52526 deleted from language.operators by danbrown

From: Date: Fri, 30 Jan 2009 20:44:19 +0000
Subject: note 52526 deleted from language.operators by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150007@lists.php.net to get a copy of this message
Note Submitter: edwardsbc at yahoo dot com ---- In response to npeelman at cfl dot rr dot com 29-Dec-2004 06:22: You have misunderstood the behaviour of the interpreter. With out the curly braces and the single quoted key identifier, the interpreter "assumes" you meant your CONSTANT to be a string. This ONLY works within a parsed (double quoted) string. And it doesn't help you at all if your array is multi-dimensional. I consider this a very bad habbit because it will get you in trouble elsewhere. Try the following: <?php define('item','AnyOldThing'); define('b',12); $arr['item']['b'] = 'string'; $arr['AnyOldThing'][12]= 'Maybe not what I intended.'; echo "This is a {$arr['item']['b']}"; // [1] prints "This is a string". echo "This is a $arr[item][b]"; // [2] broken echo $arr[item][b]; // [3] broken ?>

« previous php.notes (#150007) next »