1

Say I have this cose:

function saysomething($msg) {
    $fd = fopen(STDOUT, 'a');
    fwrite($fd, $msg);
    fclsoe($fd);
}
saysomething('test message');

That will work from the command line, but not when called as a web page. What do I need to replace the STDOUT with, to be able to write to web output?

echo outputs equally well when run either way, so I would expect it to be possible, since I can use fwrite to print to stdout. Is there a magic constant or file descriptor number or something that will let me use fwrite on a web page?

Braiam
  • 1
  • 11
  • 47
  • 78
Benubird
  • 18,551
  • 27
  • 90
  • 141
  • 4
    look at this: http://stackoverflow.com/questions/7027902/does-echo-equal-fputs-stdout took me about 5 seconds to find it. its exactly what you need – x4rf41 Sep 09 '13 at 11:54

1 Answers1

2

Use echo 'test message' instead of your own saysomething(). Or $fd = fopen('php://output', 'a'); if you prefer your current style.

Ilya
  • 4,583
  • 4
  • 26
  • 51