![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 367 Pomógł: 2 Dołączył: 4.03.2003 Skąd: C:/Windows/Temp Ostrzeżenie: (0%) ![]() ![]() |
witam
wiem ze są arty na temat engine, ale szczerze mówiąc to nie zabardzo mi wychodzi czytanie w necie (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) ale chodzi mi o to. 1.od strony teorii, o czym sie uczyć, aby w przyszłosci stworzyc swój engine??(klasy i obiekty??) 2.czy mozna skądś sciagnąć gotowy engine?? 3. hmmm tutaj zamieszczam podziękowania (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 70 Pomógł: 0 Dołączył: 3.05.2003 Skąd: Głogów Ostrzeżenie: (0%) ![]() ![]() |
class.template.php
------------------------------------ [php:1:3ba2db3e88]<?php class Template { var $tmpl; var $dane; function Template ($name) { $this->tmpl = implode('', file($name)); $this->dane = Array(); } function add($name, $value = '') { if (is_array($name)) { $this->dane = array_merge($this->dane, $name); } else if (!empty($value)) { $this->dane[$name] = $value; } } function execute() { return preg_replace('/{([^}]+)}/e', '$this->dane["1"]', $this->tmpl); } } ?>[/php:1:3ba2db3e88] test.php ------------------------------------ [php:1:3ba2db3e88]<?php include 'class.template.php'; $tmpl = new Template('test.tpl'); $tmpl->add('title', 'tytuł strony'); $tmpl->add('autor', 'imie autora'); $tmpl->add('charset', 'iso-8859-2'); $dane = Array('imie'=> 'Marcin', 'podpis'=>'jakiś tam podpis'); $tmpl->add($dane); echo $tmpl->execute(); ?>[/php:1:3ba2db3e88] test.tpl ------------------------------------ Kod <html>
<head> <title>{title}</title> <meta http-equiv="Content-type" content="text/html; charset={charset}"> </head> <body> <p>Autorem strony jest {autor}</p> <p>Witaj {imie}</p> <p>{podpis}</p> </body> </html> No to jest taki banalny :-) A jeżeli chodzi o najlepszy system szablonów, to SMARTY. :-) |
|
|
![]() ![]() |
![]() |
Aktualny czas: 3.10.2025 - 14:09 |