Using an output buffer to store contents in a file

suggest change
<?php
ob_start();
?>
    <html>
    <head>
        <title>Example invoice</title>
    </head>
    <body>
    <h1>Invoice #0000</h1>
    <h2>Cost: &pound;15,000</h2>
    ...
    </body>
    </html>
<?php
$html = ob_get_clean();

$handle = fopen('invoices/example-invoice.html', 'w');
fwrite($handle, $html);
fclose($handle);

This example takes the complete document and writes it to a file. It does not output the document to the browser. Use echo $html; when you want that.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents