我有一个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文件中
发布评论