In cases like expressions using the alternate syntax, I do not use ;
.
Example:
<?php foreach($array as $value) : ?>
<?php endforeach ?>
Some programmer friends criticized the lack of ;
after endif
, however I'm sure no one would use a ;
after closing a if
common.
So:
<?php if ($x) { ?>
<?php }; ?>
I think you're referring in your question to expressions, such as a simple echo
, or a function call.
We strongly recommend using ;
in these cases.
I often look at the frameworks source code, so I can try to improve my coding standard. And looking at the source code of Laravel 4
, I could see what it does when using the Blade syntax.
Example of a Blade code:
Meu nome é {{ $nome }} e tenho {{ $idade }} anos
Blade compiles the code this way:
Meu nome é <?php echo $nome; ?> e tenho <?php echo $idade; ?>
Then we realized that this framework was concerned with putting ;
at the end of the expression.