I like to use php function with template
Let me clarify why i want this I creating a template system that update or create view files in php dynamically.
function body($x = 1) { ?>
<?php if ($x == 1) { ?>
Congregates there is one
?>
<div class="container"> Test <?= $x ?>
<?php
}
}?>
But then it just print/echo it not i want, i want can capture it as a string. There is heredoc or nowdoc but that is not good with if, elseif, else, foreach etc. like how can i use condition here.
function child0($x = 4) {
return<<<HTML
<div class="container"> Test
$x
</div>
HTML;
}
Some Old question suggesting a complicate system for using heredoc/nowdoc