Very little programming knowledge is usually required to create a dynamic PHP page. While this does attract a lot of developers to work with PHP, the end result is source that is hardly organized – hence, described as ‘spaghetti code’.
It goes without saying that it is important to keep your the code of PHP, HTML and other presentational languages seperate for testability and maintainability.
However, if you’ve already made the mistake of mixing these languages, the use of PHP template engines might help you seperate the code of these languages.
So, here are 3 popular PHP template Engine that are worth looking at:
#1: Smarty PHP Template Engine
In being under active development for the better part of 10 years now, Smarty is probably the most widely-used template engine in the world. Some notable sites that use this template engine include Flickr, Prestashop and X-Cart. This template engine boasts of a tag-based templating feature while also supporting Online Pokies conditional and looping syntax as well as variable modifiers.
#2: Dwoo PHP Template Engine
Dwoo is one of the newer template engines as it was created in 2008 to take advantage of the object oriented capabilities that are found in PHP 5. Despite being only three years old, it has already gained widespread acceptance and has been adopted, in particular, by the TYPO3 content management system. Much like Smarty, Dwoo also supports template inheritance which allows you to override default template values.
#3: Twig PHP Template Engine
Creator of the symfony framework, Sensio Labs has also been credited with developing the Twig PHP Template Engine. Not only has this engine impressed one and all with its user manual but also creating the sandbox extension which allows you to evaluate untrusted code. Apart from this, it is noteworthy to mention that a good amount of thought has been put into allowing developers to extend the engine as well.