note 12006 deleted from language.operators.comparison by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:15:14 +0000 |
| Subject: | note 12006 deleted from language.operators.comparison by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58423@lists.php.net to get a copy of this message | ||
Note Submitter: dima@dont.spam.me.at.cc.hut.fi
----
apparantely trinary operator "?:" doesn't always work as expected if conditions are
chained, e.g. instead of
$a = (ereg("a",$b))? "aaa":
(ereg("b",$b))? "bbb":
(ereg("c",$b))? "ccc":
"other";
you need to type:
$a = (ereg("a",$b))? "aaa":
((ereg("b",$b))? "bbb":
((ereg("c".$b))? "ccc":
"other"));
to achieve desired effect.
(that is use parenteses to help the parser out)
I suspect it's a bug, because the 1st way used to work for a while and then stoppped, 2nd works
always.
Server version: Apache/1.3.9 (Unix) Debian/GNU