What engine templates are there for PHP?

Wondering what options are there for templates in PHP? If the template code can be very similar to PHP, it would be better.

0


a source to share


3 answers


I can recommend Smarty



The template is simple HTML with some extra markup for PHP calls. The template is compiled in PHP and run on the server.

+4


a source


there is an "alternative" syntax for php which makes it more attractive among html tags, I can highly recommend it.

Short tags, while mostly discouraged and / or ridiculed, also have a nice advantage:

<?php echo $variable; ?>

      

can be:



<?= $variable; ?>

      

And you can do things like:

<ul>
    <? foreach ( $myListItems as $id => $itemText ) : ?>
    <li id="<?= $id; ?>">
        <?= $itemText; ?>
    </li>
    <? endforeach; ?>
</ul>

      

What kind of minimum level template are you going to achieve with php, but it is still very readable and doesn't require you to mix in controller or model logic with your view.

+4


a source


Well, since PHP is a templating engine always ... PHP.

Some people think more needs to be added. Smarty is very popular. Personally, I have never seen the point, except for each of its own.

+2


a source







All Articles