Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

should I put a semi-colon after a single PHP statement?

Tags:

php

e.g.

some html....
<p class="date"><?php echo $date; ?></p>
more html...

?

like image 502
Haroldo Avatar asked Mar 30 '10 11:03

Haroldo


2 Answers

It might be better to always use a semi-colon :

  • Lowers the probability of errors if you need to extend your code in the specific section.
  • Improves readability of code
like image 168
Thibault Falise Avatar answered Sep 24 '22 06:09

Thibault Falise


I find that not doing so can:

  1. Break syntax highlighting in some editors / IDE (not critical, but annoying)
  2. Make code harder to maintain.

So yes, I recommend doing so, unless you are sure short tags are fine for the server config in which case its not really relevant.

When editing other people's stuff, I try to just follow the same style.

like image 39
Tim Post Avatar answered Sep 23 '22 06:09

Tim Post