Na początku witam wszystkich.
A teraz problem.
Czytałem ten artykuł
http://php.org.pl/artykuly/3/16i nie moge sobie poradzić z utworzeniem pliku templates.php stale jakiś błąd mi wyskakuje. Może ktoś mi go napisać poprawnie. A o to co mi wyszło:
php:
<?php
/******************************************************************************
* miniTemplate v. 1.2
* Prosta klasa obsługi szablonów oparta na wzorze Splatch'a (splatch@wp.pl)
******************************************************************************/
class template
{
function template($dir)
{
if($dir == \"\")
{
$this -> set_root(\"\");
}
else
{
$this -> set_root($dir);
}
return true;
}
function set_root($dir)
{
if($dir != \"\")
{
{
die(\"Template: nie mozna znalesc sciezki do szablonu.\"); }
else
{
$this -> root = $dir;
}
}
}
function set_files($files)
{
{
die(\"Template: funkcja set_files przyjmuje tylko tablice!\"); }
else
{
while(list
($tpl_id,$file) = @each($files)) {
$this -> files[$tpl_id] = $this -> root .\"\". $file;
}
}
}
function assign_vars($tpl_id,$values)
{
{
die(\"Template: funkcja assign_vars() przyjmuje wartsci tylko w tablicy.\"); }
else
{
while(list
($tag,$value) = @each($values)) {
$this -> template[$tpl_id][tag][$tag] = $value;
}
}
return true;
}
function assign_var($tpl_id,$tag, $value)
{
{
die(\"Template: w funkcji assign_var() musisz podac nazwe znacznika!\"); }
$this -> template[$tpl_id][tag][$tag] = $value;
return true;
}
function clear($tpl_id)
{
unset($this -> template
[$tpl_id]); unset($this -> template
[$tpl_id][tag
]); unset($this -> template
[$tpl_id][tag
][]); }
function compile($tpl_id,$code)
{
while(list
($key, $value) = @each($this -> template
[$tpl_id][tag
])) {
$tag = '{'.$key.'}';
{
die(\"Template: nie mozna znalesc znacznika $tag w pliku\"); }
}
return $code;
}
function pparse($tpl_id)
{
if(empty($this -> files
[$tpl_id])) {
die(\"Template: tablica <i>files</i> dla wartosci <i>$tpl_id</i> jest pusta.\"); }
$file = $this -> files[$tpl_id];
$code = @implode(\"n\",@file($file)); $gcode = $this-> compile($tpl_id,$code);
return($gcode);
}
function parse($tpl_id)
{
print($this -> pparse
($tpl_id)); }
}
?>
I pokazuje mi ,że z linijką
php:
Kod
unset($this -> template[$tpl_id][tag][]);
(linijka 87)
Coś jest nie tak tylko co Question Prosze o pomoc albo napisanie tego pliku z góry thx
Ten post edytował dez17 22.06.2005, 15:34:32