Do I need a !DOCTYPE declaration in a php file with html?

前端 未结 10 1205
面向向阳花
面向向阳花 2020-12-15 03:16

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

10条回答
  •  执笔经年
    2020-12-15 03:48

    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)

提交回复
热议问题