Jump to content

[SOLVED] write broswer output to new file


rline101

Recommended Posts

I have a file (say, output.php) which produces information which is output to a browser at present. That's good. But I need the exact browser ouptut to be turned into a text file (say, output.txt) which will be automatically saved somewhere on my disk, whenever output.php is run. How can I make this happen?

Thankyou.

Link to comment
https://forums.phpfreaks.com/topic/42918-solved-write-broswer-output-to-new-file/
Share on other sites

<?php
ob_start();
echo "This is outputted to the browser YAY!";
$browserOutput = ob_get_contents();
ob_end_clean();

$fp = fopen("filename.txt", "w+"); // note look at fopen in php.net to determine what you need here

fwrite($fp, $browserOutput);
fclose($fp);

print $browserOutput; // if you want to show that to the browser
?>

 

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.