
When it comes to template engines in PHP, many people will tell you that PHP itself is a template engine. But even if PHP started its life as a template language, it did not evolve like one in the recent years. As a matter of fact, it doesn't support many features modern template engines should have nowadays:
<?php echo $var ?>
<?php echo htmlspecialchars(\$var, ENT_QUOTES, 'UTF-8') ?>
{{ var }}
{{ var|escape }}
{{ var|e }} {# shortcut to escape a variable #}
{% for user in users %}
* {{ user.name }}
{% else %}
No user have been found.
{% endfor %}
{% extends "layout.html" %}
{% block content %}
Content of the page...
{% endblock %}
Of course, PHP is also the language for which you can find the more template engine projects. But most of them are still developed with PHP4 in mind, and do not embrace web development best practices:
{% autoescape true %}
{% var %}
{% var|raw %} {# var won't be escaped #}
{% var|escape %} {# var won't be doubled-escaped #}
{% endautoescape %}
{% include "user.html" sandboxed %}
Twig is brought to you by Fabien Potencier, the creator of the Symfony framework. Twig is released under the new BSD license.