On Fri, 2007-10-05 at 14:49 -0400, Nathan Nobbe wrote: > On 10/5/07, Jay Blanchard <jblanchard@xxxxxxxxxx> wrote: > > It looks like PHP has an "unintentional feature". Doing this; > if($r = > !$r) should always return TRUE because it is an assignment. I > don't know > if I would rely on this. > > > > its not an unintentional operation; its the order of operations. > logical ! > and the ternary ? : > takes precedence over the assignment statement > = > > http://us.php.net/manual/en/language.operators.php > > personally, i wont argue w/ the compact nature of the statement; its > nice. > its mysterious statements like this that make code fragile, imho. > i prefer the modulus approach. Actually the code used wrapped the assignment in parenthesis to ensure the assignment occurred before the ternary operator. His code is elegant, and very clear. Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ........................................................... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php