jarek
29.08.2002, 15:42:51
Witam,
Mam taki problem pisze obecnie projekt w którym chce wykorzystać templaty cos takiego jak w phpBB2. Tylko nie wiem jak sie zabrac do tego aby skrypt po przeanalizowaniu zawartosci pliku template znalazl wszystkie wyrazenia bedace w formie np. {TYTUL} i zamienil je na odpowiednie elementy tablicy w tym wypadku chcialbym aby zamienialo to na $element['TYTUL'].
Bardzo prosze o pomoc i z góry dziękuje.
pozdrawiam
jarek
Officerrr
30.08.2002, 13:08:50
z manuala php
[ciach]
str_replace (mixed search, mixed replace, mixed subject)
This function returns a string or an array with all occurences of search in subject replaced with the given replace value. If you don't need fancy replacing rules, you should always use this function instead of ereg_replace() or preg_replace().
In php 4.0.5 and later, every parameter to str_replace() can be an array.
If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well.
If search and replace are arrays, then str_replace() takes a value from each array and uses them to do search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values. If search is an array and replace is a string; then this replacement string is used for every value of search. The converse would not make sense, though.
Przykład 1. str_replace() example
$bodytag = str_replace("%body%", "black", "<body text=%body%>");
[/ciach]
hyper
30.08.2002, 13:15:52
Zamiast sikać pod wiatr proponowałbym zainteresowanie się:
Smarty -
http://smarty.php.net/
FastTemplates - idunno
haiaw
30.08.2002, 19:40:05
Cytat
Zamiast sikać pod wiatr proponowałbym zainteresowanie się:
Smarty -
http://smarty.php.net/
FastTemplates - idunno
Smarty to jeden z najbardziej rozbudowanych systemow templeatowych.
W dodatku na standardowej instalacji php ( bez akceleratorow) jest bardzo wolny.
Dlatego tez na prywatny uzytek polecam jednak Fast Templates
jarek
30.08.2002, 19:45:47
a gdzie moge zdobyc fast template?
hyper
30.08.2002, 22:08:36
Cytat
Smarty to jeden z najbardziej rozbudowanych systemow templeatowych.
W dodatku na standardowej instalacji php ( bez akceleratorow) jest bardzo wolny.
Dlatego tez na prywatny uzytek polecam jednak Fast Templates
Jesli zastosowac cachowanie strony to wcale nie wychodzi tak zle.
haiaw
30.08.2002, 23:43:46
Cytat
Cytat
Smarty to jeden z najbardziej rozbudowanych systemow templeatowych.
W dodatku na standardowej instalacji php ( bez akceleratorow) jest bardzo wolny.
Dlatego tez na prywatny uzytek polecam jednak Fast Templates
Jesli zastosowac cachowanie strony to wcale nie wychodzi tak zle.
Ale cachowanie to nie zawsze dobry pomysl. 8)
http://www.phpinsider.com/php/code/Smarty/benchmarks/