Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

would having php code before doctype make browser to go into quirks mode?

As have been discussed in one of the posts here; there was someone who dynamically attached javacript code above the doctype declaration and it then made his browser to go into quirks mode..I am currently in the same condition, only in my case I am dealing with PHP code snippet below that has to be inserted above the doctype otherwise I would get PHP "whitespace" error.

<?php session_start();
if(!session_is_registered("reg")){
    header("location:page1.php");
}?>
<!DOCTYPE html>

So would that bring my browser into quirks mode? If it would, is there any workaround? appreciate any help/suggestion. thanks.

like image 831
Benny Tjia Avatar asked Feb 24 '23 19:02

Benny Tjia


1 Answers

No. PHP code is processed before the browser consumes it. Just make sure you don't send any trailing characters after your PHP or echo anything.

like image 50
JohnP Avatar answered Mar 05 '23 18:03

JohnP