PHP offers a different way to group statements within an if statement. This is most commonly used when you nest HTML blocks inside if statements, but can be used anywhere. Instead of using curly braces, if (expr) should be followed by a colon, the list of one or more statements, and end with endif;. Consider the following example:
<?php if ($a==5): ?> A = 5 <?php endif; ?>
In the above example, the HTML block "A = 5" is nested within an if statement written in the alternative syntax. The HTML block would be displayed only if $a is equal to 5.
The alternative syntax applies to else and elseif as well. The following is an if structure with elseif and else in the alternative format:
if ($a == 5): print "a equals 5"; print "..."; elseif ($a == 6): print "a equals 6"; print "!!!"; else: print "a is neither 5 nor 6"; endif;