note 34240 deleted from control-structures by didou
| From: | didou@php.net | Date: | Sat, 09 Aug 2003 05:02:13 +0000 |
| Subject: | note 34240 deleted from control-structures by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53735@lists.php.net to get a copy of this message | ||
Note Submitter: mark [*] teckis [*] com
----
in reference to the failed ternery echo detailed above:
Inline ternery operands will work if the entire ternery is set within parenthesis - eg
echo 'some text' .(( 1 > 0 ) ? ' works' : ''). ' inline';
this can be useful for the old 'alternating table row colours' output from a while loop.
$tmp_cnt = 0;
while(........)
{
echo '<tr style="background-color:#'
.((++$tmp_cnt %2 == 0) ? 'AAA' : 'BBB').
'"><td>stuff</td></tr>';
}
note: only one function call or method can be used within either of the true/false clauses of a
ternery