Jump to content

output .php to .html file


matfish

Recommended Posts

Hi, something that sound simple but not sure how to go about it.

 

I have generated in .php an automated way to display an invoice in .php. For example, the URL would be /invoices/invoice.php?invoiceID=2

This then displays the invoice. However what I want it to do is generate and save the .html of this page to a folder under todays date, so when the above is run it saves it to /invoices/html/invoiceID2.html

 

Anyone know how to output and save the .html from a .php file?

 

Many thanks

Link to comment
https://forums.phpfreaks.com/topic/171808-output-php-to-html-file/
Share on other sites

You could cheat, and allow apache to parse it (your need the http://)

ie

$ID = (int)$_GET['invoiceID'];
file_put_contents("invoice".$ID.".html", file_get_contents("http://www.domain.com/invoices/invoice.php?invoiceID=".$ID));

 

or use ob_start();

ie

$ID = $_GET['invoiceID'];
ob_start();
//invoice code
//....
//end invoice code

//at the end save data 
file_put_contents("invoice".$ID.".html",ob_get_contents());

//and display ie
ob_end_flush();

//or clear output
//ob_end_clean();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.