I have a simple Email() class. It\'s used to send out emails from my website.
Email::send($to, $subj, $msg, $options);
?>
I also h
You can find a more elegant solution to your problem in this answer.
Notice the usage of the PHP extract function to instantiate the template variables.
In other words, you should move the template parsing logic outside the e-mail sending function.
For example:
_tpl = $tpl_name;
}
public function __set($name, $value) {
$this->_vars[$name] = $value;
}
public function setVars($values) {
$this->_vars = $values;
}
public function parse() {
ob_start();
extract($this->_vars);
include $this->_tpl;
return ob_get_clean();
}
}
abstract class Email {
public static function send($to, $subj, $msg, $options = array()) {
/* ... */
}
}
$tpl = new SimpleTemplate('/inc/email/templates/account_created.php');
$tpl->name = 'Stack Overflow';
$tpl->SITE_NAME = 'site_name';
$tpl->SITE_URL = 'localhost';
Email::send("me@localhost", "Subject", $tpl->parse());
?>