I have a php file with my website content in it. The file needs to be .php because i get some variables first and then use it later in the website content. Like this example
The same rules for HTML apply equally, whether they're plain HTML files, or HTML files with embedded PHP. YOu need a doctype in every circumstance you'd need one in plain HTML.
By the way, there's whitespace between the end of the first block oh PHP code and the doctype. I seem to remember that whitespace before the doctype can be problematic (though that might only apply to XHTML)
<!DOCTYPE HTML>
<table style="position:absolute; bottom:20%; right:40%;" width="150">
if you put <!DOCTYPE HTML>
in php file some styles will not work properly, some alignment problems.
You should always put a Doctype in your html, no matter how the html is built.
w3 doctype list
Yes, you should have the DOCTYPE
declaration, since what you send the browser is HTML, not PHP.
The declaration tells the browser that you are using HTML 5 and tells it how to render it.