F
F
Fetur2016-06-05 15:24:26
PHP
Fetur, 2016-06-05 15:24:26

How to write such code natively without a template engine?

Hello everyone, I'm learning PHP and I need to implement MVC, I'll deal with the controller and model myself, but I'm interested in this.
How to write such code as in TWIG'e, but natively in PHP?

{% if isAdmin %}
   <div>Привет админ, пора за работу!</div>
{% else %}
  <div>Приветствую пользователь!</div>
{% endif %}

Do not offer something like this:
echo '<div class="block"></div>';
$block = <<< EOF
   <div class="block"></div>
EOF;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dev400, 2016-06-05
@Fetur

<?if ($isAdmin === true) : ?>
   <div>Привет админ, пора за работу!</div>
<?else : ?>
  <div>Приветствую пользователь!</div>
<?endif?>

Владимир Грабко, 2016-06-05
@VGrabko

И вместо <?php echo $var; ?> используйте <?=$var?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question