语法错误,意外的'endif'(T_ENDIF)

时间:2017-08-08 11:47:46

标签: if-statement zend-framework

我想制作endif,但我收到了错误:

  

语法错误,

中意外的'endif'(T_ENDIF)

谁能解决这个问题?

  <div class="container">
                 <?php if ( isset($users_co_nbre) ) {
                    foreach ($users_co_nbre as $value): 
                  if($value["co_nbre"] <=10)?>
                  <div class="progress">
                    <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="<?= $value["co_nbre"]+5 ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?= $value["co_nbre"] ?>%">
                      <?= $value["first_name"] ?> <?= $value["last_name"] ?>
                    </div>
                  </div>
                    
                  <?php if($value["co_nbre"]==20&&$value["co_nbre"] ==2)?>
                  <div class="progress">
                    <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?= $value["co_nbre"]+5 ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?= $value["co_nbre"] ?>%">
                      <?= $value["first_name"] ?> <?= $value["last_name"] ?>
                    </div>
                  </div>
                 <?php endforeach; ?>
                </div>

1 个答案:

答案 0 :(得分:0)

为了清楚起见,我建议用php标签括起每个控制语句,以“:”结尾,这样你的代码稍加修改就可以了,如:

<html>
<div class="container">
  <?php $users_co_nbre = array(array('co_nbre'=>8, "first_name"=>'x', "last_name"=>'y'));?>
  <?php if ( isset($users_co_nbre) ) :?>
  <?php 			foreach ($users_co_nbre as $value):?>
  <?php            if($value["co_nbre"] <=10):?>
  <div class="progress">
    <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="<?= $value[" co_nbre "]+5 ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?= $value[" co_nbre "] ?>%">
      <?= $value["first_name"] ?>
        <?= $value["last_name"] ?>
    </div>
  </div>
  <?php endif; ?>

  <?php if($value["co_nbre"]==20 || $value["co_nbre"] ==2):?>
  <div class="progress">
    <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?= $value[" co_nbre "]+5 ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?= $value[" co_nbre "] ?>%">
      <?= $value["first_name"] ?>
        <?= $value["last_name"] ?>
    </div>
  </div>
  <?php endif; ?>
  <?php endforeach; ?>
  <?php endif; ?>