开发者

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 co开发者_C百科de for the login validation checking and the "root.php" include which is declaring the root of the project, etc.

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.

So my question is when would I want to put code above the doctype?


The headers need to be sent before the first html output, so for example if you want to use session_start() you will need to do so before the first text is sent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜