为什么有些 php 文件没有以右括号“?>”结尾?

why some php files do not end with the closing bracket "?>"?

我一直在使用 Wordpress 和其他 CMS,我注意到一些 php 文件没有结尾 ?>.

当我自己编写文件时,我必须包含?>,否则软件会崩溃。我想知道他们是如何让它工作的,或者主题的特定部分是否接受这种类型的 php 文件。也许右括号 ?> 嵌入了我没见过的另一个文件中。

有人对此有解释吗?

如果我决定将 ?> 放在这些文件上,系统会崩溃吗?或者我可以用右括号安全地写它们?

来自官方PHP文档:

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.

http://php.net/manual/en/language.basic-syntax.phptags.php