Example
End an if conditional:
html
<?php
$a = 4;
if($a < 5):
echo "Less than five";
endif;
?>
Definition and Usage
The endif keyword is used to mark the end of an if conditional which was started with the if(...): syntax. It also applies to any variation of the if conditional, such as if...elseif and if...else.
Related Pages
The if keyword.
The else keyword.
The elseif keyword.
More Examples
Example
End an if...else conditional:
html
<?php
$a = 4;
if($a < 5):
echo "Less than five";
else:
echo "Greater than five";
endif;
?>
Example
End an if...elseif...else conditional:
html
<?php
$a = 4;
if($a < 5):
echo "Less than five";
elseif($a < 10):
echo "More than five but less than ten";
else:
echo "Greater than ten";
endif;
?>