Answer the question
In order to leave comments, you need to log in
template engine. How is it better?
I don’t even know how to sum it up correctly, so I’ll just give a couple of examples.
First option:
ob_start();
$items = $db.... // Просто пример
while($item = $items->fetch_assoc()) {
echo $this->view->generate('catalog/company-item.html', $item);
}
$data = [
'companies' => ob_get_clean(),
'id' => $this->id
];
return $this->view->render('catalog/main.html', $data);
Answer the question
In order to leave comments, you need to log in
https://medium.com/@DonnaInsolita/the-evolution-of...
The first option is step 1.
The second option is ~step 4.
In short, both options are weak, but the second is closer to the correct one. Keep learning theory. Check out the right way . Understand how a similar architecture is implemented in popular frameworks.
Of these options, the second is definitely better.
And look towards twig, learn how to use it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question