【发布时间】:2017-01-18 21:32:14
【问题描述】:
请看下面的代码,我已经尝试了一个小时,现在已经放弃并来到这里! 代码在回显结束时输出错误并且没有给出任何理由,我已将其缩小到三元运算符的问题,这是我第一次使用一个,所以我不确定问题出在哪里并且已经尝试了各种... 我是不是把三进制的格式弄错了?
代码检查一个值,如果该值存在,它会用刻度符号填充第一个单元格,并将变量的值回显到第二个单元格中。
echo "<table id='tbl' class='defecttable'>
<tr>
<th>Trailer:</th>
<td>*Trailer*</td>
<th>Vehicle Mileage:</th>
<td>*vehicle mileage*</td>
</tr>
<tr>
<th>Checks To Be Made</th>
<th>Checked</th>
<th>Reportable Defect?</th>
<th>Defect Description</th>
</tr>
<tr>
<th>Fuel/Oil Leaks:</th>
<td><span class='glyphicon glyphicon-ok-circle'></span></td>
<td>".((isset($defect[fuel]) ? '<span class=glyphicon glyphicon-ok-circle"></span>': '')."</td>
<td>".((isset($defect[fuel]) ? $defect[fuel]: '')."</td>
</tr>";
【问题讨论】:
标签: php ternary-operator