php – Inserting an element within curly braces in html

Question:

Hello! There is such html code:

<title>{title}</title>
<meta name="keywords" content="{keywords}">

Instead of {title} and {keywords} information from the database is inserted. I can't understand how this happens. This is the first time I have met such a design. Maybe someone can give an example or just describe how it works

Answer:

This is a simple templating engine. Principle of operation

str_replace("{title}", $title, "<title>{title}</title>");

http://php.net/manual/ru/function.str-replace.php

Scroll to Top