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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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