Rivet;11028873 wrote:A !doctype is pretty important to use in HTML and it seems the same situation should apply to HTML within a PHP script.
First, note that there's no difference between the two, namely because the latter doesn't really exist. Whether your webserver is relaying the contents of a .html file verbatim OR the PHP scripting engine is executing a .php script that outputs data, the end result is the same - the webserver sends some data to the user's browser (which then interprets that data accordingly, e.g. as HTML markup).
Rivet;11028873 wrote:1. Without a !doctype how does a server know what type of HTML to serve? Or does it not matter somehow?
As far as your webserver is concerned, no, it doesn't matter. The webserver's job is simply to relay data from your server to any client requesting it; it couldn't care less whether or not that data contains a "doctype" or anything resembling valid HTML for that matter.
Rivet;11028873 wrote:2. Or perhaps is the doctype only needed once the first time it's used?
If you're talking about how browsers interpret and render a webpage, no, it is needed every time.
Rivet;11028873 wrote:I've looked at the Manual and at W3schools plus Google without finding it mentioned.
Which manual? If you're referring to the PHP manual, again, note that PHP couldn't care less whether or not you output any data that contains a "doctype" or anything resembling valid HTML for that matter.
As for W3schools... don't bother using it for any sort of official reference at all, lest you become a W3fool. 😉