Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A way to redirect standard output (Simply?)

4 views
Skip to first unread message

Daniel Tate

unread,
Apr 13, 2001, 4:37:00 PM4/13/01
to
In perl, you can use the select() operator to make all your output go to a
file. Is there something similar in php4? I have a program with hundreds
of print() statements. I want to be able to save the output to a file
simultaniously. Suggestions?

Thanks,
Daniel Tate.

J Lillge

unread,
Apr 13, 2001, 5:49:17 PM4/13/01
to


I think the following should work (in PHP4 only):


================================
<?
// INSERT THIS BLOCK AT THE TOP OF THE FILE
ob_start();
?>

<html><body><? print("Hello!") ?></body></html>

<?
// INSERT THIS BLOCK AT THE BOTTOM OF THE FILE
$filename = "whatever.html";
$fp = fopen($filename, "w");
$out = ob_get_contents();
fwrite($fp, $out, strlen($out));
fclose($fp);
ob_end_clean();
?>
================================


JL

danie...@gmail.com

unread,
Oct 16, 2019, 1:12:14 PM10/16/19
to
thanks

Jerry Stuckle

unread,
Oct 16, 2019, 11:48:34 PM10/16/19
to
The post you're responding to is over 18 years old. I think the OP has
probably found the solution by now.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================
0 new messages