I have a PHP file (mail-mail.php) that send some mails when a form passes him some infos, and works great.
All the mails were once inserted in the main file (mail-mail.php) like this
body = <<<BODY
-THE ENTIRE HTML CODE OF THE MAIL-
BODY;
File become very huge (mail-mail.php send 3-5 mails everytime that runs) very long (more than 500 lines), and not comfortable if i have to change the mail contents
So i decided to take the entire mail code out and replaced them with some external files with the HTML code of the mail.
$body = file_get_contents('./mail/inv.php');
Inside the HTML code there is a variable ($name) that in the <<
I tried to load the file separately in this way
$body = str_replace("$name", $name, file_get_contents('./mail/inv.php'));
or this way
$prebody = file_get_contents('./mail/inv.php');
$body = str_replace("$name", $name, $prebody);
but still the $prebody (and the $body of course) loads "inv.php" without changing the $name value.