php 没有“?>”的文件
php file without "?>"
我试过像这样写一个简单的 php 文件(并且成功了):
<?php
echo("OK");
我的问题是:
写 php 文件末尾没有“?>”是否安全?
是的,documented结尾的结束标记是可选的。
事实上,如果您不使用它更好,因为如果您这样做,有时源代码末尾的额外空格会在您不使用时最终出现在输出中我不想这样。
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.
当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.
我试过像这样写一个简单的 php 文件(并且成功了):
<?php
echo("OK");
我的问题是:
写 php 文件末尾没有“?>”是否安全?
是的,documented结尾的结束标记是可选的。
事实上,如果您不使用它更好,因为如果您这样做,有时源代码末尾的额外空格会在您不使用时最终出现在输出中我不想这样。
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.
当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.