为何有些PHP文件没有收尾符
如题,文档的最后没有以?>收尾。有什么特别的原因吗? 有啊,这样的写法有很多好处,比如不会出现?>后不小心多出的空白字符,导致你的程序里 http header 发送不出去,等等很多问题。 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. 谢谢楼上的详细解释~!
页:
[1]