note 34240 added to control-structures
| From: | mark at rack1 dot php dot net | Date: | Sat, 19 Jul 2003 12:34:12 +0000 |
| Subject: | note 34240 added to control-structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52380@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/control-structures.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34240
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34240&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34240&report=yes