note 27688 added to language.operators
| From: | eric at themepark dot com | Date: | Mon, 16 Dec 2002 02:46:56 +0000 |
| Subject: | note 27688 added to language.operators | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40942@lists.php.net to get a copy of this message | ||
note that the ternary operator comes BEFORE the "." (string concatenate) operator... so
$a = 'eric is a '.(1) ? 'goofball' : 'kitty-cat';
echo $a;
this snippet returns "goofball" instead of "eric is a goofball".
$a = 'eric is a '.((1) ? 'goofball' : 'kitty-cat');
echo $a;
This snippet returns "eric is a goofball".
this little oversight bit me on the metaphorical ass :-) so hopefully this'll help others...
--
http://www.php.net/manual/en/language.operators.php
http://master.php.net/manage/user-notes.php?action=edit+27688
http://master.php.net/manage/user-notes.php?action=delete+27688
http://master.php.net/manage/user-notes.php?action=reject+27688