Jump to content

Good Coding Practice


kigroy

Recommended Posts

Question about coding practice:

 

Is it better to separate your php code from your html unless you need the php code to generate a variable amount of html code (i.e. using a loop command to create rows or columns on a table)?

 

or to have the entire page created by php?

 

The reason I ask is I was trying to code with php creating all the html code when I was discussing something with a programmer and he said to NEVER do that.  That it only creates confusion and only should be done when you are dealing with a variable amount of columns or rows in a table.

 

Thoughts?

 

BTW, I was using php to create all code based off some examples I found here at phpfreak.com. 

Link to comment
https://forums.phpfreaks.com/topic/136944-good-coding-practice/
Share on other sites

For large applications, it's often best practice to separate logic from presentation, yes. Often template engines (such as the one built into the majority of frameworks) are used to do just that. When it really gets down to it for large applications, I will often use an MVC framework such as Zend to simplify the separation. For small, run-occasionally applications? Meh, why bother.

Link to comment
https://forums.phpfreaks.com/topic/136944-good-coding-practice/#findComment-715293
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.