On Mon, Dec 31, 2012 at 5:47 PM, Stephen <stephe...@rogers.com> wrote:
> The common stuff for every page is defined in the file "include.php". I
> define the variable $markup in that file.
>
> Here is the definition for $markup
>
> $markup=<<<HEREDOC
[[snippy]]
> HEREDOC;
>
> By using require_once instead of fopen and fread, I have simpler code and
> PHP evaluates the embedded variables in $markup without any need to use
> string functions.

While using the *_once works in many cases, if you're doing a mass
mailing kind of thing, you want to use the standard include/require so
you can re-include it as your variables change:

foreach ($customers as $customer) {
  $fullname = $customer['fullname'];
  $address = $customer['address'];
  // and so on
  include("mailing.php");
  process($mailing,$customer);
}

where mailing.php defines the $mailing variable as the content that
got included and substituted.

(Back before I came up with this, I was starting off in the same place
as the OP -- and then I just realized "wait --- PHP *IS* a templating
system!" a voila)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to