渲染后输出html页面

时间:2016-08-10 09:12:54

标签: php html

美好的一天!

我希望能够在渲染后使用PHP获取HTML文档的内容。例如,如果我有这个HTML文档:

<html>
    <head>
    <script>
        function(){
            /* some dummy code here*/
        }
    </script>
    </head>
    <body>
        <form>
            <div> 
                <a href="some_links"> click here friend </a>
                <input type="button" />
                <p>Lorem ipsum dolor sit atmen</p>
            </div>
        </form>
    </body>
</html>

该函数的输出应如下所示:

点击此处朋友

Lorem ipsum dolor坐在atmen

提前感谢您的帮助! 注意:请不要太在意这个HTML代码,这只是一个例子

2 个答案:

答案 0 :(得分:0)

输出缓冲应该完成这项工作:

<?php
   ob_start();
?>

all of your HTML

<?php
   $content = ob_get_content();
    echo strip_tags($content);
?>

答案 1 :(得分:0)

您将拥有一个PHP文件并使用includerequire

例如。

<强>的index.php

<?php
  function getHTML() {
   include 'test.html';
  }
  getHTML();
?>

<强>的test.html

<html>   
    <body>
        <form>
            <div> 
                <a href="some_links"> click here friend </a>
                <input type="button" />
                <p>Lorem ipsum dolor sit atmen</p>
        </form>
    </body>
</html>