开发者

Why do I have PHP code above the doctype?

开发者 https://www.devze.com 2022-12-18 16:24 出处:网络
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.

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

精彩评论

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