Question

My company uses an invoice software I've made. It's a simple page that copies input from fields, checkboxes and some dynamic table with Javascript into a new page with A4 CSS so it can be printed or sent via mail as PDF.

Now I have to start on the second feature: open an invoice. I have thought of one way I could make this.

When a new invoice is made and input is copied into the other page, to also copy all the HTML from the form in which all the inputs are into a text file with PHP - and later when a user "opens" an invoice, it just opens the file which just copies all the HTML code.

I don't know how to copy part of the code into a text file. If you also know an easier, better way please tell.

Was it helpful?

Solution

Use output buffering.

Before you render anything out to the browser do

ob_start();

after you do your rendering get the html content.

$html = ob_get_contents();

then to send it to the browser do.

ob_flush();

Then with the $html you can save to file, database or whatever works for your use case

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top