Can I please know the difference between
<?php if() : ?>
<?php endif; ?>
and
<?php if() { ?>
<?php } ?>
Can I please know the difference between
<?php if() : ?>
<?php endif; ?>
and
<?php if() { ?>
<?php } ?>
this is just alternative syntax called braceless syntax
If you follow MVC design pattern then only your view files should have HTML in them to begin with. Using the braceless syntax in these files only further separates them thematically from the rest of the code.
The major advantage of braceless syntax is that braces get lost while jumping into and out of php mode, especially if you use php short tags.
There is no difference, it's down to your preference.
Personally I use the former when inside a view, the latter everywhere else.
Inside a view:
<div>
<p>Cake?</p>
<?php if (true): ?>
<p>Cake!</p>
<?php endif; ?>
</div>
Elsewhere:
echo 'Cake?';
if (true) {
echo 'Cake!';
}