Why do some scripts omit the closing PHP tag, '

2019-01-01 04:51发布

This question already has an answer here:

In some scripts I see that they omit writing a closing tag ?> for the script. Why is it and should I do this as well?

(I'm sure they have not forgotten it.)

7条回答
不流泪的眼
2楼-- · 2019-01-01 05:45

Modern versions of PHP set the output_buffering flag in php.ini. If output buffering is enabled, you can set HTTP headers and cookies after outputting HTML, because the returned code is not sent to the browser immediately.

Are the examples still valid in this context?

查看更多
登录 后发表回答