php if elseif else endif

Syntax with "endif" used mostly in complex templates where easier to find "endif" than "}":

<?php
if($a > $b):
	echo $a.' is greater than '.$b;
elseif($a < $b):
	echo $a.' is less than '.$b;
else:
	echo $a.' equals '.$b;
endif;
?>

Classic syntax:

<?php
if($a > $b){
	echo $a.' is greater than '.$b;
}elseif($a < $b){
	echo $a.' is less than '.$b;
}else{
	echo $a.' equals '.$b;
}
?>
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

One thought on “php if elseif else endif

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">