By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,569 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,569 IT Pros & Developers. It's quick & easy.

Sending output to a file

P: n/a
Lets say I got something simple like:

<?php

echo "yo";
echo "word";

?>

I want all those echos to write to a file instead of printing to the screen
without changing to a different function. Sort of like how in Unix you can
do ./my_prog < file1 to output to a file. In this case I want it all to be
done in code. For example, something like:

<?php

output_to_file_instead_of_screen();

echo "yo";
echo "word";

output_to_screen();

?>
Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Xizor" <no**@nope.com> schrieb:
Lets say I got something simple like:

<?php

echo "yo";
echo "word";

?>

I want all those echos to write to a file instead of printing to the screen
without changing to a different function.


If I got it right, you don't want to use a switch in the function for
echo() and fwrite(). In this case you could use output buffering. Your
program can catch the output and write it to a file at the end of the
script. Have a look at the output control functions at
http://www.php.net/manual/en/ref.outcontrol.php.

Matthias
Jul 16 '05 #2

P: n/a
I did look at the manual. I looked under file functions and streams (cause C
did this with streams). Didn't see it in either. Matthias pointed out the
output control functions, which I missed. Thanks to him, not to you.
"Ian.H [dS]" <ia*@WINDOZEdigiserv.net> wrote in message
news:n1********************************@4ax.com...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Thu, 31 Jul 2003 16:47:31 GMT, "Xizor"
<no**@nope.com> amazingly managed to produce the following with their
Etch-A-Sketch:
Lets say I got something simple like:

<?php

echo "yo";
echo "word";

?>

I want all those echos to write to a file instead of printing to
the screen

So read the PHP Manual on http://www.php.net/. This is _VERY_ basic
stuff.. you did RTFM didn't you?

Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPylMcGfqtj251CDhEQLtXgCg5CsGhqRMunu/WIbUSjx0EQsm5gMAoKoy
GGbA8GzWJEzEtdKZ2gfFw0h8
=Xxjd
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

Jul 16 '05 #3

P: n/a
Thank you. Good stuff.

"Matthias Esken" <mu************@usenetverwaltung.org> wrote in message
news:bg*********@usenet.esken.de...
"Xizor" <no**@nope.com> schrieb:
Lets say I got something simple like:

<?php

echo "yo";
echo "word";

?>

I want all those echos to write to a file instead of printing to the screen without changing to a different function.


If I got it right, you don't want to use a switch in the function for
echo() and fwrite(). In this case you could use output buffering. Your
program can catch the output and write it to a file at the end of the
script. Have a look at the output control functions at
http://www.php.net/manual/en/ref.outcontrol.php.

Matthias

Jul 16 '05 #4

P: n/a
"Xizor" <no**@nope.com> schrieb:
I did look at the manual. I looked under file functions and streams (cause C
did this with streams). Didn't see it in either. Matthias pointed out the
output control functions, which I missed. Thanks to him, not to you.


Well, I think Ian got the question wrong.

Hope this output control works for you.

Matthias
Jul 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.