⊗ppPmSFEIB 291 of 447 menu

Elseif Block in Conditions for Breaking PHP Code

You can also make multiple conditions using elseif:

<?php if ($test === 1) { ?> <p>1</p> <?php } elseif ($test === 2) { ?> <p>2</p> <?php } else { ?> <p>?</p> <?php } ?>

Let's rewrite it using the alternative syntax:

<?php if ($test === 1): ?> <p>1</p> <?php elseif ($test === 2): ?> <p>2</p> <?php else: ?> <p>?</p> <?php endif; ?>

Given divs:

<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>

Make a condition that will show one of the divs.

byenru