> -----Original Message----- > From: Andrey Hristov [mailto:[EMAIL PROTECTED] > Sent: 12 March 2003 17:26 > > > On Wed, 12 Mar 2003, Andrey Hristov wrote: > > > > > Few minutes ago I found the following behaviour somehow > wierd for me : > > > > Known bug, the associativity of the ternary operator has been > > broken since ages in the engine. It's on the "won't be > > fixed" sheet, because of BC concerns.
That's a bit hard -- it's different from c, certainly (left associative instead of right), but that's a valid choice (even if it was originally accidental!) and calling it broken is a bit harsh. > > Is it documented somewhere? Yes -- at http://www.php.net/manual/en/language.operators.php#language.operators.prece dence). Just to make this completely clear, in left-associative PHP b = a==1? 4:a==2? 5:6; is equivalent to b = (a==1? 4:a==2)? 5:6; yielding 5 if a==1 or a==2, else 6. But in right-associative c, it's equivalent to: b = a==1? 4:(a==2? 5:6); yielding 4 if a==1, 5 if a==2, else 6. Since this *is* documented behaviour, I don't see how it can be called particularly unexpected. ("Weird", maybe, if you're used to the c behaviour, but not unexpected!) Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php