Blocul elseif în condiții pentru întreruperea codului PHP
De asemenea, puteți face mai multe condiții folosind
elseif:
<?php if ($test === 1) { ?>
<p>1</p>
<?php } elseif ($test === 2) { ?>
<p>2</p>
<?php } else { ?>
<p>?</p>
<?php } ?>
Să rescriem folosind sintaxa alternativă:
<?php if ($test === 1): ?>
<p>1</p>
<?php elseif ($test === 2): ?>
<p>2</p>
<?php else: ?>
<p>?</p>
<?php endif; ?>
Sunt date div-urile:
<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>
Creați o condiție care va afișa unul dintre div-uri.