Jump to content

php above <html> causes IE to enter quirks mode


fixxxer

Recommended Posts

hi,

 

ive just built a new menu for a site of mine. it works fine in firefox but in IE it doesn't, ive been told that because my code is :-

 

<?php

session_start();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>

....etc

 

that this causes internet explorer to enter some sort of quirks mode and render the page differently.

my problem is that i also thought the session_start has to be the first line. is there a way for me to combine them both and ensure IE displays page as firefox does.

 

ive been trying for two days to resolve it but am having no luck

 

thanks

 

Link to comment
Share on other sites

it only causes a problem when i put session_start(); above the html doc declaration like in the example in the first post but if i just have code in there like :-

 

<?php

echo 'test';

$var = 'test';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>

etc..

 

this will load the menu fine, but as soon as i put session_start(); in there the menu doesn't work. theres nothing wrong with the code becuase it works in firefox fine and the problem only occurs if i put in session_start(); in the php section above the header. has anybody every had a problem like this?

 

I found other posts on the net of people who have similar problems but no solution.

 

it might be becuase im not very good then. but can i then ask how users on here start their pages.

 

ive always done mine as :-

 

<?php

//php code

?>

<html .... with the doctype here.

 

is this right

Link to comment
Share on other sites

That's impossible.. A simple session_start() funcion can't write any HTML to the document.

 

I make my page, one with php and the index page, I then include the php page on the top of the index page and let the php page set the values of the varuabls too be shown on the index page.

Link to comment
Share on other sites

thanks. dont know whats causing it. its not that the session_start(); is writing anything to the page but that i was under the impression that IE need the DOCTYPE declaration needs to be at the top and for some reason when i put session_start in it causes IE to go into quirks mode and so doesn't read the css correctly.

 

when i leave the session_start() out the page displays fine and the drop down menu works. but when it goes back in i get an error.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.