Save current page as HTML to server

后端 未结 6 1802
一生所求
一生所求 2020-11-29 19:05

What approach could someone suggest to save the current page as an HTML file to the server? In this case, also note that security is not an issue.

I

6条回答
  •  迷失自我
    2020-11-29 19:17

    I think we can use Output Control Functions of PHP, you can use save the content to the variable first and then save them to the new file, next time, you can test it the html file exists, then render that else re-generate the page.

     time()) )
    {
        $content = file_get_contents($cacheFile);
        echo $content;
    } else
    {
        ob_start();
        // write content
        echo '

    Hello world to cache

    '; $content = ob_get_contents(); ob_end_clean(); file_put_contents($cacheFile,$content); echo $content; } ?>

    Example taken from : http://www.php.net/manual/en/function.ob-start.php#88212

提交回复
热议问题