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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.