[英]Why do I have PHP code above the doctype?
I'm still learning this stuff, but for the most part, my understanding is that you want code in the head or the body. 我仍在学习这些东西,但是在大多数情况下,我的理解是您希望头部或身体中的代码。 I'm working with a page that is a login page. 我正在使用作为登录页面的页面。
Above the doctype is all the php code for the login validation checking and the "root.php" include which is declaring the root of the project, etc. 在doctype上方是用于登录验证检查的所有php代码,其中的“ root.php”包括用于声明项目的根目录等。
Is this the way things should be done? 这是应该做的事情吗?
If I move the doctype to the top, I get an error. 如果我将文档类型移到顶部,则会出现错误。 As it is, the browser sees the doctype as the top item when I view source. 照原样,当我查看源代码时,浏览器将doctype作为头条。
So my question is when would I want to put code above the doctype? 所以我的问题是我什么时候要将代码放在doctype之上?
标头需要在第一个html输出之前发送,因此,例如,如果要使用session_start(),则需要在发送第一个文本之前发送。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.