RE: [PHP] Alternate Colors in Rows ($r=!$r)
| From: | Robert Cummings | Date: | Fri, 05 Oct 2007 19:10:13 +0000 |
| Subject: | RE: [PHP] Alternate Colors in Rows ($r=!$r) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262842@lists.php.net to get a copy of this message | ||
On Fri, 2007-10-05 at 14:04 -0500, Jay Blanchard wrote:
> [snip]
> The value of the expression is the value assigned. Since the ! operator
> will always return a boolean then the assigned value is going to be a
> boolean. So $r will always contain a boolean for the purposes of the
> ternary operation.
>
> And it also work if the statement is not ternary
> [/snip]
>
> And now for a little clarity. THIS is not a ternary
>
> if($r = !$r)
>
> it is a conditional test.
>
> ? foo : bar;
>
> ...is the ternary operation. Just wanted to clean up the usage there.
Did I miss something? The code I saw was the following:
<TR class=<?php echo ($r = !$r) ? "dataRow1" : "dataRow2"; ?> >
And that is definitely using the ternary operator. At any rate, in the
above where you have:
if($r = !$r)
The rules are the same and the value received by the if conditional will
always be a boolean.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................