tags:

views:

157

answers:

6

for example

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

It's really up to you. I do, as it helps me with code readability.

adam
+4  A: 

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
Thibault Falise
+1  A: 

As you do use long tags it doesn't really matter. Personally I do use short tags in my templates and it goes to be extremely handy without semicolon, just <?=$var?>, <? endif ?> and such.

But in the long sheets of code I always use semicolons.

Col. Shrapnel
+2  A: 

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.

Tim Post
A: 

This particular little idiosyncrasy is discussed in the instruction separation manual page.

The bottom line is that it's not enforced either way, so it's left up to the programmer. It's a decent item to touch on in any sort of PHP coding standard, but as far as standards go, it's a relatively minor issue.

Personally, I have started always using a trailing semi-colon. It's easier on your IDE, and helps avoid those quick little parse errors when you jump into a template and start appending code (especially in a verbose template, that might not have user-friendly line wrapping).

zombat
A: 

I'd recommend it, if for no other reason than it's a good habit to get into, like properly indenting html.

StormShadow