Skip to content

Instantly share code, notes, and snippets.

@WenLiangTseng
Created July 22, 2013 05:46
Show Gist options
  • Save WenLiangTseng/6051535 to your computer and use it in GitHub Desktop.
Save WenLiangTseng/6051535 to your computer and use it in GitHub Desktop.
PHP使用HTML郵件版型
<?php
/*You could put a PHP script inside the template
and then have PHP itself do the rendering,
for example:
*/
//template.html:
?>
<div clas="headr"></div>
<div class="content"><?php echo $body; ?></div>
<div class="footer"></div>
<?php
//Then to load it, in your PHP code:
$body = "Put this into the content tag...";
ob_start();
include("template.html");
$email = ob_get_clean();
/* Edit: in this case it's perhaps a bit overkill
to use my method instead of a simple replace,
but if instead of replacing the entire email
message you wanted to have a more complicated
template, it makes it easy. E.g.:
*/
?>
<table>
<tr>
<td>Name:</td>
<td><?php echo $name; ?></td>
</tr>
<tr>
<td>Email:</td>
<td><?php echo $email; ?></td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment