开发者

Storing results of script execution to a file

I have built an estimating application where I type in some fields hit submit and the data is saved to my database and creates an on the fly estimate with everything that I typed in. Now they issue I am having is I want to save the output page as a file to my webserver for later viewing, but I can only find examples that save all of my code including the ECHO $Field1. How can I save the outputted results to a file. The same results one would see if they right clicked on the outputted page and choose view source. I was hoping to do it only using PHP.

I tried this already.....

<?php
ob_start();
// all your logic and code for displaying
$output = ob_get_contents();
file_put_contents($uniquehtml,$output开发者_JS百科);
// save output page to the html file
?> 


use something like this in your output page

//buffer output
ob_start();

//process form
//your code goes here

//save & flush buffer in a file
$buffer = ob_get_flush();
file_put_contents('buffer.txt', $buffer, FILE_APPEND);

The FILE_APPEND keeps adding output to the same file. Otherwise, create a new file name each time it writes. You could append time() to the file name, for instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜