在Apache PHP标准输出 [英] PHP stdout on Apache
问题描述
在Windows 7中的Apache 2.2使用PHP 5.3作为php5_module。
Using PHP 5.3 as php5_module in Apache 2.2 on Windows 7.
在哪里标准输出上面的配置去了?
Where does stdout go in the above configuration?
与下面code下测试:
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?
推荐答案
由于在 PHP手册显示://包装的手册页:
的的php://输出的是一个只写流,使您可以写信给
以同样的方式作为输出缓冲机制的打印和回声
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.
所以,如果你想要写输出到浏览器中,使用 PHP://输出
So if you want to write output to the browser, use php://output
在另一方面, PHP://标准输出
允许的相应的输入或输出流的直接访问
PHP的过程。
allow direct access to the corresponding input or output stream of the PHP process.
在Apache的情况下,该输出是Apache的标准输出句柄,通常是从来没有见过的任何地方,因为这是为Apache控制台输出,它通常是在后台运行。如果你要在前台您的控制台上运行Apache,任何你写 PHP://标准输出
将在控制台上可见。因为Apache是在后台运行,没有标准输出
捕获数据或任何写入正常。
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:
- 运行的Apache在前台(例如
的/ usr /本地/ Apache2的/ bin中/ httpd的-D FOREGROUND -K启动
) - 将控制台窗口打开
- 从浏览器中运行你的脚本
- 查找在控制台上的
标准输出
输出。
- 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.
这篇关于在Apache PHP标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!