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

后端 未结 5 687
南笙
南笙 2021-01-07 20:13

e.g.

some html....

more html...

?

5条回答
  •  情话喂你
    2021-01-07 21:00

    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).

提交回复
热议问题