Possible Duplicate:
Problem when loading php file into variable (Load result of php code instead of the code as a string)
I am bit confused about following…
message alert function
public static function MsgAlert($email, $name, $subject, $message)
{
$msg = include('mailer.php');
$subject = 'New Message';
if ($email != '' && validate_email($email))
{
$mailer = new PHPMailer();
$mailer->SetFrom(ADMIN_EMAIL, SITE_NAME);
$mailer->AddAddress($email);
$mailer->Subject = $subject;
$mailer->Body = Postman::nl2br($msg);
$mailer->AltBody = $msg;
$mailer->Send();
}
}
I have put my newsletter design into mailer.php, and please check markup for that…
mailer.php
<div>
<h1><?php $subject; ?><span>27 September 2011 at 6:26 pm</span></h1>
<div>
<p>Hello <?php $name; ?>,</p>
<?php $message; ?>
</div> <!--message container -->
</div>
Am i using correct approach or should i do something more better as its not working. please suggest. thanks.
You cannot include to a variable, but what you can do is use php’s output buffering functions to achieve the desired outcome, e.g.:
This will render the template and store the result in
$msg.