将当前页面保存为HTML到服务器 [英] Save current page as HTML to server
问题描述
有人建议将当前页面保存为HTML文件到服务器的方法是什么?在这种情况下,请注意安全性不是问题。
我花了无数个小时来搜寻这些内容,并且没有找到
$ b 您的帮助非常感谢,谢谢!
编辑
谢谢大家的帮助,非常感谢。
如果你的意思是将一个页面的输出保存在一个文件中,你可以使用缓冲来做到这一点。您需要使用的功能是 ob_start 和 ob_get_contents 。
<?php
//开始缓冲//
ob_start();
?>
您的页面内容bla bla bla bla ...
<?php
echo'1';
//获取缓冲区中的内容并将其放入文件中//
file_put_contents('yourpage.html',ob_get_contents());
?>
这会将页面内容保存在 yourpage.html
。
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 have spent endless hours searching around for this, and have not found a single thing.
Your help is much appreciated, thank you!
Edit
Thank you all for your help, it was very much appreciated.
If you meant saving the output of a page in a file, you can use buffering to do that. The function you need to use are ob_start and ob_get_contents.
<?php
// Start the buffering //
ob_start();
?>
Your page content bla bla bla bla ...
<?php
echo '1';
// Get the content that is in the buffer and put it in your file //
file_put_contents('yourpage.html', ob_get_contents());
?>
This will save the content of the page in the file yourpage.html
.
这篇关于将当前页面保存为HTML到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!