|
Posted by petersprc on 11/19/06 10:26
Hi,
You probably won't notice any performance issues unless you have
enormously high request volume... str_replace would be faster than a
regex in general. There's also Smarty templates and straight PHP like
so:
mailer.php:
foreach ($subscriptions as $sub) {
ob_start();
require('email-template.php');
$text = ob_get_contents();
ob_end_clean();
mail($sub['email'], 'Subscription Confirmation', $text,
"From: My Site <info@mysite.com>");
}
email-template.php:
Dear <?= $sub['name'] ?>: You subscribed to <?= $sub['list'] ?>.
Erwin Moller wrote:
> Hi Group,
>
> At the moment I am developing a app that uses templates.
> In the templates I have placeholders like this:
>
> Dear ***FIRSTNAME***<br>
> You have subscribed to ***LISTSUBSRIBE***.
> etc
>
> The ***XXXX*** must be replaced with values created in my script.
>
> I am a bit worried about the speed and wonder which approach will be
> fastest.
> A straightforward solution would be to run a
> str_replace($arrSearch,$arrReplace), where
> $arrSearch contains the strings to be replaced by the corresponding values
> in $arrReplace.
>
> Is this a fast solution?
> Will a regexpression approach be faster?
>
> Does anybody have experience with this or advise?
> Or should I just try a few and benchmark it?
>
> TIA!
>
> Regards,
> Erwin Moller
Navigation:
[Reply to this message]
|