I'm don't use PHP that much and right now I'm stuck at a problem. I need to save the site of a webbrowser as a pdf. I'm using right now mPDF (which was suggested in a wiki of stackoverflow) and it seems to work pretty well (I just have simply write a short html code into a php variable and then created the pdf).
But now I must get the html code of the actual site in the browser and save it then into a php variable. How can I do that?
If I understand you correctly, you can store page contents into php variable like this:
ob_start();
// your html code goes here
$contents = ob_get_contents();
ob_end_clean();
// see the contents now
echo $contents;
You can probably fetch the remote content via PHPs file_get_contents()
-function:
$html = file_get_contents('http://example.org');
If this does not work, make sure that you have allow_url_fopen
enabled in your php.ini.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With