为什么一些脚本省略关闭PHP标签'?>'? [英] Why do some scripts omit the closing PHP tag, '?>'?

查看:73
本文介绍了为什么一些脚本省略关闭PHP标签'?>'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些脚本中,我看到他们省略了为脚本编写结束标记?> 。为什么是这样,我应该怎么做呢?

In some scripts I see that they omit writing a closing tag ?> for the script. Why is it and should I do this as well?

(我相信他们没有忘记它。)

(I'm sure they have not forgotten it.)

推荐答案

好吧,省略结束标签只是一个避免空格和其他字符在文件末尾的解决方案。例如,在尝试稍后修改标题信息时,意外添加到结束标记后面的任何字符都会触发错误。

Well, omitting the closing tag is just one solution for avoiding blanks and other characters at the end of file. For example any char which is accidentally added behind the closing tag would trigger an error when trying to modify header info later.

删除结束标记是一种良好做法请参阅许多编码指南。

Removing the closing tag is kind of "good practice" referring to many coding guidelines.

这篇关于为什么一些脚本省略关闭PHP标签'?>'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆