<?php
/*
* Класс шаблонизатора
*/
class Template{
/*
* @var string;
*/
const DIR = "tpl/";
/*
* Открытие файла
* @params string
*/
public function load($file_name){
$this->_dir = self:😁IR.$file_name.'.tpl';
if(!file_exists($this->_dir)){
exit("Файла " .$this->_dir." не существует!!!");
return false;
}
$this->temp = file_get_contents($this->_dir);
}
/*
* Метод для замены %маркеров%
* @params string
* @params string
*/
public function set($search, $replace){
$this->temp = str_replace('%'.$search.'%', $replace, $this->temp);
}
/*
* Вывод файла на экран
*/
public function display(){
echo $this->temp;
}
}
?>
/*
* Класс шаблонизатора
*/
class Template{
/*
* @var string;
*/
const DIR = "tpl/";
/*
* Открытие файла
* @params string
*/
public function load($file_name){
$this->_dir = self:😁IR.$file_name.'.tpl';
if(!file_exists($this->_dir)){
exit("Файла " .$this->_dir." не существует!!!");
return false;
}
$this->temp = file_get_contents($this->_dir);
}
/*
* Метод для замены %маркеров%
* @params string
* @params string
*/
public function set($search, $replace){
$this->temp = str_replace('%'.$search.'%', $replace, $this->temp);
}
/*
* Вывод файла на экран
*/
public function display(){
echo $this->temp;
}
}
?>