下面的php if语句不起作用。查询(个案)是空的,但是当它为空时它不会显示else语句。
<?php foreach ($cases as $case): ?>
<?php if(!$cases->isEmpty()): ?>
<tr>
<td><?= h($case->plaintiff) ?> </td>
<td><?= h($case->defendant) ?></td>
<td><?= h($case->case_number) ?></td>
<td><?= $this->Html->link(_('View'), ['controller' => 'Cases', 'action' => 'view', $case->id], array('class' => 'btn btn-xs btn-success')) ?></td>
</tr>
<?php else: ?>
<tr>
<td colspan="4">No Related Cases</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
答案 0 :(得分:0)