dongya4089 2009-05-30 09:50
浏览 81
已采纳

将PHP页面转换为静态HTML页面的最简单方法

I want to convert a web pages which is heavily CSS styled is written in PHP to static html so that I can embed it in an email.

I have managed to do this but for achieving this I had to convert the whole page into a string and then assign that string as email body. The layout of the page does not look as good as original as I have not been able embed CSS.

This approach has a few problems like if any changes have to be made to the layout of the page I have to redo the whole process for generating an embeddable page.

I want an easier way which will allow me to keep the original page editable in Dreamweaver visually.

  • 写回答

4条回答 默认 最新

  • dongwen4630 2009-05-30 09:57
    关注

    You can use output buffers. If you have an html page, such as:

       <html>
          <head>
             <title>Blah</title>
          </head>
          <body>
            Some text here
          </body>
       </html>
    

    Then if you put, at the top of the html file:

    <?php ob_start(); ?>
    

    And right at the bottom, after the last tag, put:

    <?php 
       $string = ob_get_contents(); 
    
       //do whatever you need to do to the html, save it to a seperate file, email it, etc
    
       ob_flush();
    ?>
    

    What this basically means is that the $string variable will end up with the entire static html of the page, after it has been dynamically generated. You can then use that string in an email. Although really, html pages don't work exactly the same in emails, so you may want to rethink the approach.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题