in reply to Code and html separation - always or mostly doable?
Second way (mixing logic and presentation):if ($u_level == 0) { $bgcolor = "#FF0000"; } else if ($u_level == 1) { $bgcolor = "#0000FF"; } # tons of code... print<<<HTML <HTML> <HEAD> <TITLE> DaWolf's silly example </TITLE> </HEAD> <BODY BGCOLOR="$bgcolor"> <!-- tons of content... --> </BODY> </HTML> HTML;
The advantage of the second way in my point of view is that you don't need to go all the way up to understand what $bgcolor means and why it have this or that value, so the code is more easily understandable and more practical to debug.# tons of code... print<<<HTML1 <HTML> <HEAD> <TITLE> DaWolf's silly example </TITLE> </HEAD> HTML1; if ($u_level == 0) { print "<BODY BGCOLOR=\"#FF0000\">"; } else if ($u_level == 1) { print "<BODY BGCOLOR=\"#0000FF\">"; } print<<<HTML2 <!-- tons of content... --> </BODY> </HTML> HTML2;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Code and html separation - always or mostly doable?
by cfreak (Chaplain) on Jun 17, 2004 at 04:12 UTC | |
Re^2: Code and html separation - always or mostly doable?
by kiat (Vicar) on Jun 17, 2004 at 05:29 UTC |