![]() |
my way of templating, is this a good method?
in terms of speed and low cpu loads, is this a good way to go?
$html = file_get_contents("home.tpl"); $html = str_replace("%fname%", $firstname, $html); $html = str_replace("%lname%", $lastname, $html); echo $html; |
The method is fine, it doesn't allow for much growth templating wise though.
|
It's ok if you only need search&replace.
|
This is more of a general comment than anything particularly specific to templating but remember that
str_replace can accept arrays for the first three arguments (respectively: search, replace, subject). This saves the overhead of calling the same function more than once in succesion, and prevents you from repeating code unnecessarily. More simply, you could use:PHP Code:
|
| All times are GMT. The time now is 06:06 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0