PHPendif Keyword
Example
End anif conditional:
<?php
$a = 4;
if($a < 5):
echo "Less than five";
endif;
?>
Try it Yourself »$a = 4;
if($a < 5):
echo "Less than five";
endif;
?>
Definition and Usage
Theendif keyword is used to mark the end of anif conditional which was started withtheif(...): syntax. It also applies to any variation of theif conditional, such asif...elseif andif...else.
Related Pages
Theif keyword.
Theelse keyword.
Theelseif keyword.
Read more about conditional statements in ourPHP if else Tutorial.
More Examples
Example
End anif...else conditional:
<?php
$a = 4;
if($a < 5):
echo "Less than five";
else:
echo "Greater than five";
endif;
?>
Try it Yourself »$a = 4;
if($a < 5):
echo "Less than five";
else:
echo "Greater than five";
endif;
?>
Example
End anif...elseif...else conditional:
<?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;
?>
Try it Yourself »$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;
?>

