0

My approach:

<?

switch($id) 
{ 
    case 1:
?>
        a lots of html stuff goes here...
<?    
    break;  
    case 2:
?>
        a lots of html stuff goes here2...
<?    
    break;        
}

?>

Is there any way to do this thing prettier? I mean more readable or something? I would really appreaciate that. (haven't learned smarty yet...)

0

4 Answers 4

9

Break out the HTML into separate files and include them in the relevant blocks.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, probably that's the best solution here.
1

include as has been mentioned. Or if you really want to separate it out you could use a template engine such as Smarty

1 Comment

Smarty won't help in this very case. And such a separation should be done in mind, not code. Smarty has {PHP} tag as well....
0

if statements might be cleaner here:

<? 
if ($id == 1) {  
?> 
        a lots of html stuff goes here... 
<?     
}
if ($id == 2) {
?> 
        a lots of html stuff goes here2... 
<?     
} 
?> 

Comments

0

I'd recommend a full templating solution like Smarty (which Cfreak has mentioned already), it is a good idea to separate presentation from logic.

1 Comment

I realize that, however I find the code ugly, and it allows for more of a separation between presentation and logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.