Why would one omit the close tag?

前端 未结 14 1555
旧巷少年郎
旧巷少年郎 2020-11-21 06:18

I keep reading it is poor practice to use the PHP close tag ?> at the end of the file. The header problem seems irrelevant in the following context (and this

14条回答
  •  [愿得一人]
    2020-11-21 07:15

    It's pretty useful not to let the closing ?> in.

    The file stays valid to PHP (not a syntax error) and as @David Dorward said it allows to avoid having white space / break-line (anything that can send a header to the browser) after the ?>.

    For example,

    
    [space here]
    [break line here]
    

    won't be valid.

    But

    will.

    For once, you must be lazy to be secure.

提交回复
热议问题