我想为我的网站创建电子邮件模板。
所以我想说这是我的template_header.php
:
<html>
<head>
<title>
'.$email_subject.'
</title>
</head>
<body>
这是我的template_footer.php
:
</body>
</html>
据我所知,我可以使用输出缓冲来包含这些模板。 这是我的代码:
<?php
ob_start();
include "template_header.php";
?>
<p>Text</p>
<?php
include "template_footer.php";
$message = ob_get_contents();
ob_end_clean();
?>
但它不起作用! $message
是空的!即使我做var_export($message)
,我什么也得不到!甚至不是一个空字符串。
答案 0 :(得分:0)
这对我有用。
ob_start();
//print all the things - and I mean print. echoing and plain html work.
$message = ob_get_clean();
echo $message;