我们看exec调用命令的输出,常常是空的。原因在于命令的输出不是输出到stdout的,而是stderr。

exec("rm 1.txt" , $out);

改为

exec("rm 1.txt 2>&1" , $out);


0(stdin,标准输入)、1(stdout,标准输出)、2(stderr,标准错误输出),默认与keyboard、monitor、monitor有关

[精华] I/O重定向 详解及例子!
http://www.chinaunix.net/jh/24/484163.html

Posted on 2007-01-31 13:19  古代  阅读(1196)  评论(0编辑  收藏  举报