How to write such code without native template engine?

Hi all, learn PHP and you want to implement MVC with a controller and model will handle it, and I'm interested in this.
How to write such code as in TWIG'e, but the native PHP?
{% if isAdmin %}
 the <div>Hello admin, time for work!</div>
{% else %}
 the <div>Welcome user!</div>
{% endif %}

Something like that not offer:
echo '<div class="block"></div>';
$block = <<< EOF
 <div class="block"></div>
EOF;
July 8th 19 at 16:35
2 answers
July 8th 19 at 16:37
Solution
<?if ($isAdmin === true) : ?>
 the <div>Hello admin, time for work!</div>
<?else : ?>
 the <div>Welcome user!</div>
<?endif?>
And is it possible? If so, very cool and thank you. I will try to test. - Beth_Kuphal commented on July 8th 19 at 16:40
: this is an example of templating in php, if you have it tvig installed, then first copy all - Kendrick_Schu commented on July 8th 19 at 16:43
although usually do the opposite - Kendrick_Schu commented on July 8th 19 at 16:46
: I just twogam enjoyed the work and liked the way I would like to know how to do it native because tvig still converts it to php code. - Beth_Kuphal commented on July 8th 19 at 16:49
you have in TPL files, php execution is disabled - Kendrick_Schu commented on July 8th 19 at 16:52
: I have now in your own project no tviga, and view php files. All allowed) Strange, but your method does not work. I understand that if without else, we simply replace the colon on the braces? - Beth_Kuphal commented on July 8th 19 at 16:55
: no, from endif - Kendrick_Schu commented on July 8th 19 at 16:58
I understand you already got, but please tell me that I incorrectly wrote here?


- Beth_Kuphal commented on July 8th 19 at 17:01
: Okay, got it, do not kick me. Forgot echo. Thank you very much Andrew. - Beth_Kuphal commented on July 8th 19 at 17:04
: hmm. I have written to you an example of standardization - Kendrick_Schu commented on July 8th 19 at 17:07
Here is a live example of the project, if so clear
<h1 class="page-header"><?= $this--->title ?></h1>

<?if ( $msg === null): ?>

<?foreach ($model as $cat_data) : ?>
 <form method="post" role="form">

 <div class="row">

 <div class="form-group col-sm-3">
<h5>Title</h5>
 <label class="sr-only" for="name">Name</label>
 <input value="<?= $cat_data[" cat_name"] ?>" type="text" onkeyup="translit()" class="form-control" name="category_name" id="name" required placeholder="Name">
</div>

 <div class="form-group col-sm-3">
<h5>Link(Url)</h5>
 <label class="sr-only" for="url">Url</label>
 <input value="<?= $cat_data[" cat_url"] ?>" type="text" class="form-control" id="url" name="category_url" required placeholder="Url">
</div>

 <div class="form-group col-sm-6">
 <h5>Parent category</h5>
 <select name="parent_cat" size="1">
 <option value="0">No parent category</option>
 <?foreach ( $all_cats as $data ) : ?>
 <option <?="($data["id"]" =="=" $cat_data["parent"]) ? "selected" : ""> value="<?= $data["id"] ?>"><?= $data["cat_name"] ?></option>
<?endforeach?>
</select>
</div>
</div>


 <input type="hidden" name="category_id" value="<?= $cat_data[" id"] ?>" />
 <button type="submit" class="btn btn-default">Edit category</button>
</form>

<?endforeach?>


<?else :?>
 <?= $msg ?>
<?endif?>
- Kendrick_Schu commented on July 8th 19 at 17:10
July 8th 19 at 16:39
Instead use

Find more questions by tags TwigPHP