Alternative control statement for PHP

PHP offers alternative for control statements just for developers who did not want to see lot of curly brackets ‘{ }’ in their code.

<?php
if($access):
//and close it with
endif;
?>

It’s also applicable to else statement:

<?php
if($access):
//code here
else:
//code here
endif;
?>

This alternative method can also be used for foreach.

Leave a Reply

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