On 12 April 2011 20:00, David Harkness <david.h@xxxxxxxxxxxxxxxxx> wrote: > On Tue, Apr 12, 2011 at 6:34 AM, Richard Quadling <rquadling@xxxxxxxxx> > wrote: >> >> Without running the code, can you say what the output will be in the 3 >> examples? > > Yes, but I would still rewrite that code. ;) I typically reserve the ternary > operator to return a value or assign a variable. Given that it is used less > frequently combined with its precedence in PHP differing from other > languages make using it in complicated expressions prone to errors and > misunderstanding by others. > Adding parentheses avoids interpreter errors but doesn't lessen the > likelihood of another developer breaking the code if they modify it. > David > No matter what one developer uses a ternary for, it can be used as in inline if/then/else. And as such, not keeping track of the precedence is what will make for some very interesting debugging exercise. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php