e.g.
some html....
<p class="date"><?php echo $date; ?></p>
more html...
?
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
I find that not doing so can:
- Break syntax highlighting in some editors / IDE (not critical, but annoying)
- 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.
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).
It's really up to you. I do, as it helps me with code readability.
I'd recommend it, if for no other reason than it's a good habit to get into, like properly indenting html.
精彩评论