Session or Doctype first?

I was having trouble with errors trying to put Session_start() near the top of my web page - until I put it above the Doctype stuff. But I thought Doctype had to be the first thing on an html page. (Everybody wants to be first).
So now I have Session_start() on line 1 surrounded by php tags, and Doctype on line 2.
Will the Doctype information be processed?

Second question: I didn’t have any problem in my shop creating this on Windows. I can’t even make it happen. The problem only occurs at my ISP on Linux. It seems like the Doctype is sending header info or something that disagrees with Session_start, which is trying to set a cookie. Why would it be so different?

The session_start() is a server-side scripting statement that will result in a Cookie header being sent in the HTTP response. All headers must precede the response body (which starts with the doctype declaration).

Unless you use output buffering of some sort, you need to start the session before you output anything (including the doctype declaration) to the response stream.

But, does anyone know if:
1 Will the Doctype be processed properly
2. Why does it not have the problem in my shop.

Yes it will be sent properly, since session_start() produces no real output (i.e., will not be visible in the HTML). If your still confused please open the source of your web page and look at the first line. Voila, the doctype, nothing to be seen about session_start().

As AutisticCuckoo already suggested, your shop probably has output buffering enabled in the php.ini

Yes, that’s it. Output buffering is set up in my php.ini.
I didn’t read the earlier post that way. I was only thinking about me setting it up in my code if I wanted to. That didn’t make me think that maybe it was already set up that way.

And I have been viewing source code all day. I just wasn’t sure about why it had to be at the top, or if seeing it there in the running code was good enough. Not sure how to tell if it’s working either - whatever it does :>)

This session project is to log in users and display their name at the top of the pages - pretty typical. But now I guess I have to go through every page on the site and start a session as the first thing. Unless anybody has any better ideas?