irken Posted December 13, 2006 Share Posted December 13, 2006 Hello.I'm pondering weather I should (and can, legally) do like below, or if I should use 'print' to display the HTML code. The below workes fine, but that's not a reason for it to be correct :-). Thank you for reading.[code]<?php // Start/resume session. session_start(); // username if (!$_SESSION['navn']) {?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head> <title>Login</title></head><body> <form action="checklogin.php" method="post"> <p> <input id="txtNavn" type="text" name="Navn" /><br /> <input id="txtKode" type="password" name="Kode" /><br /> </p> <input id="btnLogin" type="submit" value="Login" /> </form></body></html><?php } else { echo 'Logout before logging in again.'; }?>[/code] Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 13, 2006 Share Posted December 13, 2006 It's all a matter of preference, but I will say, if I remember correctly, that IE will choke on that empty line between your ?> and <!DOCTYPE Quote Link to comment Share on other sites More sharing options...
monkey_05_06 Posted December 13, 2006 Share Posted December 13, 2006 PHP is designed so that you can enter and exit PHP coding as often in your script as you'd like. I don't know if there will be problems with the blank space or not as roopurt18 says (I'm not saying he's wrong, I'm just saying I don't know), but you can use PHP only where needed or you can use it for all output or technically you could even generate no output via PHP and just name your HTML pages as PHP pages (though this doesn't make any sense there shouldn't be any adverse effects to doing so). ;) Quote Link to comment Share on other sites More sharing options...
irken Posted December 13, 2006 Author Share Posted December 13, 2006 Great, thanks alot for the quick replies :). Quote Link to comment Share on other sites More sharing options...
irken Posted December 14, 2006 Author Share Posted December 14, 2006 [quote author=roopurt18 link=topic=118518.msg484329#msg484329 date=1166044960]... that IE will choke on that empty line between your ?> and <!DOCTYPE[/quote]Hmm. I've not experienced that myself - but you might be right. I'm using IE 7 and so far no problems. I'd really love to be able to make these kind of spaces too, because I've got such a weak spot for clean looking code :-).I'll have to try it out in older versions of IE, altho I was thinking of just limiting access for IE browser 6 and above. I really don't have the heart, not "skills" to figure out all the different ways these browsers parses things. Firefox acts way differently than IE. Which of them are not following the official guidelines ? :D Quote Link to comment Share on other sites More sharing options...
monkey_05_06 Posted December 14, 2006 Share Posted December 14, 2006 I don't think any one browser sticks entirely to the standard, though I know that IE definitely has quite a bit of IE-specific coding specifications that most other browsers will not render properly. FF tends to have less of this. But if you want to be sure you should check the W3's verification tools. Those will define the official standard. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.