Save current page as HTML to server(将当前页面另存为 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 到服务器


基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01