一个回声有一个三元运算符,回声是一个跨度
An echo with has an ternary operator which echo's a span
请看下面的代码,我已经尝试解决这个问题一个小时了,现在已经放弃了,来到这里!
该代码在回显结束时输出错误,并且没有给出任何原因,我已将其缩小为三元运算符的问题,这是我第一次使用三元运算符,所以我不确定问题出在哪里,并且各种都试过了...
我的三进制格式错了吗?
代码检查一个值,如果该值存在,它会用刻度符号填充第一个单元格,并将变量的值回显到第二个单元格中。
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>";
非常接近,但有几件事要看。
- 在你的每个
isset
之前都有一个额外的 (
。
- 您是指使用
$defect['fuel']
而不是 $defect[fuel]
吗?如果您没有用单引号或双引号将燃料括起来,则假定它是一个常数。
结果:
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>";
请看下面的代码,我已经尝试解决这个问题一个小时了,现在已经放弃了,来到这里! 该代码在回显结束时输出错误,并且没有给出任何原因,我已将其缩小为三元运算符的问题,这是我第一次使用三元运算符,所以我不确定问题出在哪里,并且各种都试过了... 我的三进制格式错了吗?
代码检查一个值,如果该值存在,它会用刻度符号填充第一个单元格,并将变量的值回显到第二个单元格中。
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>";
非常接近,但有几件事要看。
- 在你的每个
isset
之前都有一个额外的(
。 - 您是指使用
$defect['fuel']
而不是$defect[fuel]
吗?如果您没有用单引号或双引号将燃料括起来,则假定它是一个常数。
结果:
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>";