将一个php文件的输出保存在一个html文件中 [英] Save output of a php file in a html file

查看:106
本文介绍了将一个php文件的输出保存在一个html文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php文件,它执行一些代码来生成一个html文件。它像我有一个表单,其中一些数据将被发布到x.php文件,它提供了一个输出(一个网页)。我希望将输出保存在html文件中。什么是最有效的方式?

编辑
我想要把它保存在服务器端。其实,事情是我想创建的PDF文件..我写了一切。现在的事情是我想保存在HTML页面的输出。所以,我可以将其转换成PDF文件..

解决方案

试试这样:

  / /开始输出缓冲
ob_start();
//在x.php文件中运行代码
// ...
//将捕获的输出保存到文件
file_put_contents('filename.htm',ob_get_contents());
//结束缓冲并显示页面
ob_end_flush();

如果您不能使用 ob_ * functions ,您也可以将表单写入一个变量,然后保存该变量。


I am having a php file which executes some code to generate a html file.Its like I m having a form from which some data will be posted to x.php file, which gives a output(a webpage). I want to save that output in a html file.What the most efficient way of doing this.?

EDIT I want to save it on sever side. Actually the thing is i want to create pdf file for that.. I wrote everything else.Now the thing is i want to save the output in a html page.So that i can convert it into pdf file..

解决方案

Try something like this:

// Start output buffering
ob_start();
// run code in x.php file
// ...
// saving captured output to file
file_put_contents('filename.htm', ob_get_contents());
// end buffering and displaying page
ob_end_flush();

If you cannot use the ob_* functions, you can also write the form to a variable and then save that variable.

这篇关于将一个php文件的输出保存在一个html文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆