2017-01-18 2 views
1

입니다. 아래 코드를 참조하십시오. 한 시간 동안 이것을 알아 내려고 노력하고 있으며, 포기하고 여기에와 있습니다! 코드는 에코의 끝을 출력하고 어떤 이유로 든 제공하지 않습니다. 삼항 연산자로 문제를 좁혔습니다. 문제가있는 곳을 잘 모르겠다. 그리고 모든 종류를 시도했습니다 ... 3 자 형식이 잘못 되었습니까?에코와 함께 삼진 연산자가 있습니다. 반향 문자는

값이 존재하면 코드는 첫 번째 셀을 눈금 글리프로 채우고 변수 값이 두 번째 셀에 에코됩니다.

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>"; 

답변

1

아주 가깝지만 살펴볼 몇 가지 사항.

  • 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>";