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:
- Run Apache in the foreground (e.g.
/usr/local/apache2/bin/httpd -D FOREGROUND -k start
)
- Leave the console window open
- Run your script from the browser
- Look for your
stdout
output on the console.