note 12006 added to language.operators.comparison.php

From: Date: Sat, 17 Mar 2001 21:07:46 +0000
Subject: note 12006 added to language.operators.comparison.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12510@lists.php.net to get a copy of this message
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 http://www.php.net/manual/en/language.operators.comparison.php

« previous php.notes (#12510) next »