Jump to content

Recommended Posts

I've asked people before on what their opinions are for using a template type of system with PHP, or using the actual PHP code with HTML in the same file.

 

I know the template system is more organized, but takes longer for the code to run. So, what should I start using if I were to work on some real projects?

Link to comment
https://forums.phpfreaks.com/topic/231759-php-html-or-separated/
Share on other sites

Template systems are overkill IMO, there are better ways of separating code (logic) from presentation (markup) without the extra overhead.

 

A well designed application should allow most (if not all) of your logic to be separated from markup with only minimal amounts of PHP ending up amongst your HTML. I've posted an example of this on the boards here before, I'm not sure this was the exact one I was thinking of but it's about all my search could find. See http://www.phpfreaks.com/forums/index.php?topic=320371.msg1510211#msg1510211

Template systems can be very useful (especially when creating some sort of style engine). They do an effective job at keeping your PHP logic away from your display, which is good for medium to larger sized projects that require that sort of abstraction. Although there is a learning curve, it is often worth it for the benefits you get. I personally use Twig for my projects, and I can speak for it's performance.

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.