沃梦达 / 编程问答 / php问题 / 正文

将当前页面另存为 HTML 到服务器

Save current page as HTML to server(将当前页面另存为 HTML 到服务器)

本文介绍了将当前页面另存为 HTML 到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人建议用什么方法将当前页面作为 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!

编辑

感谢大家的帮助,非常感谢.

Thank you all for your help, it was very much appreciated.

推荐答案

如果您的意思是将页面的输出保存在文件中,您可以使用缓冲来实现.您需要使用的函数是 ob_start 和 ob_get_contents.

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());
?>

这会将页面内容保存在文件yourpage.html中.

This will save the content of the page in the file yourpage.html.

这篇关于将当前页面另存为 HTML 到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:将当前页面另存为 HTML 到服务器

基础教程推荐