将一个php文件的输出保存在一个html文件中

编程入门 行业动态 更新时间:2024-10-28 03:31:12
本文介绍了将一个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文件中

本文发布于:2023-08-05 11:24:47,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   在一   php   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!