Using PHP 5.3 as php5_module in Apache 2.2 on Windows 7.
Where does stdout go in the above configuration?
Tested with following code:
<?php
$stdout = fopen('php://stdout', 'w');
fwrite($stdout, "stdout<br />\n");
$output = fopen('php://output', 'w');
fwrite($output, "output<br />\n");
?>
This only displays output
in the browser. What happens to stdout?
As the manual shows on the php:// wrappers manual page:
php://output is a write-only stream that allows you to write to the output buffer mechanism in the same way as print and echo.
So if you want to write output to the browser, use php://output
On the other hand, php://stdout
allow direct access to the corresponding input or output stream of the PHP process.
In the case of Apache, this output is Apache's stdout handle which is generally never seen anywhere because this is console output for Apache and it is usually run in the background. If you were to run Apache in the foreground on your console, anything you write to php://stdout
would be visible on the console. Since Apache is run in the background, no stdout
data is captured or written anywhere normally.
To test this, follow these steps:
/usr/local/apache2/bin/httpd -D FOREGROUND -k start
)stdout
output on the console.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