class Templater {
public function render($file) {
include $file;
}
public function __get($name) {
return $this->$name;
}
}
$tmpl = new Templater();
$tmpl->name = 'Bob';
$tmpl->render('template.php');
<? echo $this->name ?>
protected function render($view,$params = [])
{
ob_start();
// внутри main.php будет доступна переменная $params
// и переменная $this - указатель на текущий объект
include ROOT.'/views/layouts/main.php';
return ob_get_clean();
}
<?= $this->getContents() ?>
<div class="bubble">
<div class="bubble-in">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit ipsa quisquam deserunt rerum repellendus consequuntur iste inventore et dolorum natus. Suscipit saepe facilis fugit reprehenderit earum. Quibusdam expedita iusto mollitia!
</div>
</div>
.bubble {
width: 300px;
border-radius: 15px;
border: 3px solid #1AA0D2;
display: inline-block;
position: relative;
}
.bubble::after {
content: '';
width: 39px;
height: 50px;
border-left: 3px solid #1AA0D2;
border-bottom: 5px solid #1AA0D2;
position: absolute;
bottom: -20px;
left: 40px;
background: white;
transform: skewX(-30deg) skewY(-48deg);
}
.bubble-in {
border-radius: 12px;
padding: 30px;
background: white;
position: relative;
z-index: 2;
}