arxiba 发表于 2008-7-26 08:24:08

为何有些PHP文件没有收尾符

如题,文档的最后没有以?>收尾。有什么特别的原因吗?

Hex 发表于 2008-7-26 11:28:34

有啊,这样的写法有很多好处,比如不会出现?>后不小心多出的空白字符,导致你的程序里 http header 发送不出去,等等很多问题。

沧蓝 发表于 2008-7-26 21:40:07

Kohana与Zend Framework等框架都是推荐省略收尾的。

ZF的官方文档:

http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html

For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response.

arxiba 发表于 2008-7-27 19:40:32

谢谢楼上的详细解释~!
页: [1]
查看完整版本: 为何有些PHP文件没有收尾符