[英]Include text from other files in PHP
我想為我的網站創建電子郵件模板。
所以說這是我的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)
,我也var_export($message)
!!! 甚至沒有一個空字符串。
這對我有用。
ob_start();
//print all the things - and I mean print. echoing and plain html work.
$message = ob_get_clean();
echo $message;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.