thetylercox Posted June 14, 2012 Share Posted June 14, 2012 So more of an aesthetics question. Where do you put what when coding or what is the preferred order? example! style html head script php head body Speaking in the case of order does not matter! Yes I get that it does just curious how some of you organize your code. Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/ Share on other sites More sharing options...
floridaflatlander Posted June 14, 2012 Share Posted June 14, 2012 You may be over thinking it. An example is the style or jscript can go on it's own page or in the html header between tags. Php can be on it's own page then included in an web page or enter woven in the web page. Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353637 Share on other sites More sharing options...
thetylercox Posted June 14, 2012 Author Share Posted June 14, 2012 I'm obviously over thinking it lol! Was just curious if anyone had an order they stick to that they somehow find pleasing! Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353638 Share on other sites More sharing options...
antmeeks Posted June 14, 2012 Share Posted June 14, 2012 The most aesthetically pleasing thing is to keep all your scripting out of your html. You could do something like this: <script language="php">include('my_fantastic_script.php');</script> <html> <head> <title><?=$title?></title> <link rel="stylesheet" href="<?=$stylesheet?>" type="text/css" /> <script type="text/javascript" src="<?=$javascript?>"></script> </head> <body> <div id="wrapper"> <div id="left_col"> <h1><?=$h1_title?></h1> <?=$content?> </div> <div id="right_col"> <?=col_content?> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353657 Share on other sites More sharing options...
Jessica Posted June 14, 2012 Share Posted June 14, 2012 Even when you do a plain <style> section rather than a separate file, doesn't it have to go within the HTML, not before your opening html tag? Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353847 Share on other sites More sharing options...
mrMarcus Posted June 14, 2012 Share Posted June 14, 2012 Even when you do a plain <style> section rather than a separate file, doesn't it have to go within the HTML, not before your opening html tag? I does not have to, no. But it will not validate and is U-G-L-Y. Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353850 Share on other sites More sharing options...
RobertP Posted June 14, 2012 Share Posted June 14, 2012 Even when you do a plain <style> section rather than a separate file, doesn't it have to go within the HTML, not before your opening html tag? nothing should be before your html tag, except your doctype doctage <html> <head> ... </head> <body> ... </body> </html> & some reading material: http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-scope Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353957 Share on other sites More sharing options...
jcbones Posted June 14, 2012 Share Posted June 14, 2012 I do all of my processing before the output. Only echo'ing inside of HTML. Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353994 Share on other sites More sharing options...
antmeeks Posted June 15, 2012 Share Posted June 15, 2012 nothing should be before your html tag, except your doctype +100 I do all of my processing before the output. Only echo'ing inside of HTML. +1000 Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1354020 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 15, 2012 Share Posted June 15, 2012 nothing should be before your html tag, except your doctype That should really be phrased as no style sheets, javascript or HTML should be before your HTML tag. PHP is frequently, and most usually SHOULD be before any HTML. CSS, and Javascript (unless its absolutely necessary to place it somewhere else), should be inside the head tag. And it is of course better to get all CSS, and as much Javascript and PHP as possible out of the actual documents that contain HTML. Where PHP is necessary in HTML is to format the display with conditionals. Quote Link to comment https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1354045 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.