Shartlar uchun PHP kodini uzishda elseif bloki
Shuningdek,
elseif yordamida bir nechta shartlarni yaratish mumkin:
<?php if ($test === 1) { ?>
<p>1</p>
<?php } elseif ($test === 2) { ?>
<p>2</p>
<?php } else { ?>
<p>?</p>
<?php } ?>
Keling, muqobil sintaksis orqali qayta yozamiz:
<?php if ($test === 1): ?>
<p>1</p>
<?php elseif ($test === 2): ?>
<p>2</p>
<?php else: ?>
<p>?</p>
<?php endif; ?>
Divlar berilgan:
<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>
Divlardan birini ko'rsatadigan shart yarating.