Blok elseif dalam syarat untuk memutuskan kod PHP
Anda juga boleh membuat beberapa syarat dengan menggunakan
elseif:
<?php if ($test === 1) { ?>
<p>1</p>
<?php } elseif ($test === 2) { ?>
<p>2</p>
<?php } else { ?>
<p>?</p>
<?php } ?>
Tulis semula menggunakan sintaks alternatif:
<?php if ($test === 1): ?>
<p>1</p>
<?php elseif ($test === 2): ?>
<p>2</p>
<?php else: ?>
<p>?</p>
<?php endif; ?>
Diberi div:
<div>
<p>text1</p>
<p>text1</p>
<p>text1</p>
</div>
<div>
<p>text2</p>
<p>text2</p>
<p>text2</p>
</div>
<div>
<p>text-</p>
<p>text-</p>
<p>text-</p>
</div>
Buat syarat yang akan menunjukkan salah satu div.