首页 > 解决方案 > 从 php 控制器将 html 文件呈现为 html

问题描述

更新:

有人可以解释为什么第一种方法显示为纯文本,而第二种方法显示为 html?我正在尝试将文件内容显示为 html。

    <?php
echo getcwd() . '<br>';

方法一

$body = file_get_contents('wp-content/themes/twentytwelve-child/views/html/email-footer.html');
echo $body;

方法二

$body = '<!DOCTYPE html> <html>
   <head>
       <style>
           div{
               font-size:5vw!important;
              }
         #img1{
               width:100%!important;
              }
       </style>
</head>
<body lang=EN-US>
   <div style="text-align:center;margin:0 auto;font-size:16px">
      <!-- <img id="img1" style="width:70%;" src="cid:swag-logo">-->
       <p> Hi, <br><br> Thank you for your interest in Sustainable Weston
           Action Group. If you would like to sign up for our quarterly
           newsletter or have specific areas of interest/expertise that you
           would like to share,please complete  
           <a href=" https://www.sustainablewestonma.org/get-involved/" >our 
           Get Involved form</a> This information is for Sustainable Weston
           Action Group use only - we will not share your information with any 
           other parties.<br><br><br>Sustainable Weston Action Group</p>
    </div>
</body>
</html>';

echo $body; 

?>

标签: phphtmlrender

解决方案


推荐阅读