|
|
|
|
<?php
$file = "{date} {hello} {content} {date2}";
$content = "Hello World";
$tags = array (
'{content}' => $content,
);
$file_replace = str_replace($tags, $content, $file);
echo $file_replace;
?>
|
Пишу систему шаблонов, но код не работает! Выводит только "{date} {hello} {content} {date2}"!!! | |
|
|
|
|
|
|
|
для: R@zoR
(02.08.2007 в 08:37)
| | может изза того что вы ассоциативный массив в качестве первого параметра посылаете... | |
|
|
|
|
|
|
|
для: malish
(02.08.2007 в 08:41)
| | Ой, точно! СпС! | |
|
|
|
|
|
|
|
для: R@zoR
(02.08.2007 в 08:37)
| |
<?php
class tpl
{
var $file = NULL;
var $file_replaced = NULL;
function load_template($tpl_name)
{
if (!file_exists($tpl_name)) die("Невозможно открыть $tpl_name!");
$this->file = file_get_contents("test.tpl");
}
function set($name, $variable)
{
$this->file_replaced = str_replace($name, $variable, $this->file);
}
function render()
{
echo $this->file_replaced;
}
}
$fuck = "fuck";
$tpl=new tpl();
$tpl->load_template("test.tpl");
$tpl->set("{date}", $fuck);
$tpl->render();
?>
|
кароче вот, дописал! | |
|
|
|