用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3646|回复: 3
收起左侧

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

[复制链接]
发表于 2008-7-26 08:24:08 | 显示全部楼层 |阅读模式
如题,文档的最后没有以?>收尾。有什么特别的原因吗?
发表于 2008-7-26 11:28:34 | 显示全部楼层
有啊,这样的写法有很多好处,比如不会出现?>后不小心多出的空白字符,导致你的程序里 http header 发送不出去,等等很多问题。
发表于 2008-7-26 21:40:07 | 显示全部楼层
Kohana与Zend Framework等框架都是推荐省略收尾的。

ZF的官方文档:

http://framework.zend.com/manual ... ile-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.
 楼主| 发表于 2008-7-27 19:40:32 | 显示全部楼层
谢谢楼上的详细解释~!

本版积分规则