Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有的echo有一个三元运算符,它echo#x27;这是一个跨度_Php_Ternary Operator - Fatal编程技术网

Php 带有的echo有一个三元运算符,它echo#x27;这是一个跨度

Php 带有的echo有一个三元运算符,它echo#x27;这是一个跨度,php,ternary-operator,Php,Ternary Operator,请看下面的代码,我已经试着弄明白这一点一个小时了,现在已经放弃了,来到这里! 代码在回音的末尾输出了一个错误a,它没有给出任何原因,我已经把它缩小到三元运算符的问题,这是我第一次使用它,所以我不确定问题在哪里,并尝试了各种方法。。。 我把三元组的格式弄错了吗 代码会检查值,如果该值存在,它会用记号符号填充第一个单元格,变量的值会回显到第二个单元格中 echo "<table id='tbl' class='defecttable'> <tr> &l

请看下面的代码,我已经试着弄明白这一点一个小时了,现在已经放弃了,来到这里! 代码在回音的末尾输出了一个错误a,它没有给出任何原因,我已经把它缩小到三元运算符的问题,这是我第一次使用它,所以我不确定问题在哪里,并尝试了各种方法。。。 我把三元组的格式弄错了吗

代码会检查值,如果该值存在,它会用记号符号填充第一个单元格,变量的值会回显到第二个单元格中

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”
拖车:
*拖车*
车辆里程:
*车辆里程*
支票
选中的
可报告缺陷?
缺陷描述
燃油/机油泄漏:

“((isset($defect[fuel])?”非常接近,但有几点需要注意

  • 每个
    设置之前都有一个额外的
  • 您的意思是使用
    $defect['fuel']
    而不是仅使用
    $defect[fuel]
    ?如果您不使用单引号或双引号将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”
拖车:
*拖车*
车辆里程:
*车辆里程*
支票
选中的
可报告缺陷?
缺陷描述
燃油/机油泄漏:
“(isset($defect['fuel'])?”