Mam takie coś:
<?php
class template
{
public $dir = "templates/default/"; // katalog z szablonami
public $file; // plik szablonu
public $tags; // tagi
public function __construct($file, $tags = NULL)
{
$this->file = $file; // ustala plik
foreach($tags as $tag => $tagvalue)
{
$this->tags["{".$tag."}"] = $tagvalue; // dodaje tag
}
}// end of construct
public function tag($tags, $value = NULL) // dodaje nowe tagi
{
{
foreach($tags as $tag => $tagvalue)
{
$this->tags["{".$tag."}"] = $tagvalue; // dodaje tag
}
}
else
{
$this->tags["{".$tag."}"] = $tagvalue; // dodaje tag
}
}// end of tag
public function display() // wyświetla szablon
{
$tmp = preg_replace("#\(\.(.*?)\.\)#", "", $tmp); // komentaarze echo $tmp; // wyświetla obrobiony wynik }// end of display
}// end of template
?>
A następnie tak się do tego odwołuję:
$error_type = "Bład";
$szablon = new template("msg_error.tpl");
"U_TYPE_ERROR" => $error_type,
"U_MSG_ERROR" => $msg_error,
"U_FILE" => $file,
"U_LINE" => $line)
);
Efekt:
Invalid argument supplied for foreach() in /home/majkelo/public_html/strona/includes/template.class.php on line 11
Przy czym, linia 11 to:
foreach($tags as $tag => $tagvalue)
Przecież jest jak byk tablica tutaj:
"U_TYPE_ERROR" => $error_type,
"U_MSG_ERROR" => $msg_error,
"U_FILE" => $file,
"U_LINE" => $line)
więc czemu strzela takie 'fochy'?