繁体   English   中英

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

[英]Save output of a php file in a html file

我有一个php文件,它执行一些代码来生成一个html文件。就像我有一个表单,一些数据将被发布到x.php文件,它提供一个输出(一个网页)。 我想将该输出保存在html文件中。这是最有效的方法。

编辑我想将它保存在服务器端。 实际上,我想为此创建pdf文件..我写了其他所有内容。现在我想将输出保存在html页面中。所以我可以将其转换为pdf文件..

尝试这样的事情:

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

如果您不能使用ob_ *函数 ,您还可以将表单写入变量,然后保存该变量。

使用ob_*函数(如ob_get_contents() ,php脚本可以捕获它的输出。

查看ob函数(请参阅http://php.net/manual/en/function.ob-start.php ),它允许您从页面捕获每个输出(回声,打印等)。

可能有ob_start和output_callback,请参阅http://php.net/manual/en/function.ob-start.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM