从windows(PHP)中的exec()输出?

时间:2011-10-28 18:39:47

标签: php exec

似乎没有从PHP,OS:Windows XP中获取exec()命令的输出

这是使用的代码: exec(“echo%username%”,$ output);

使用print_r($ output)返回1;

1 个答案:

答案 0 :(得分:2)

echo不是Windows上可以调用的程序。它是命令处理器专门提供的功能(即cmd.exe)。

如果您想以这种方式使用用户名,请不要启动shell。请改用getenv

(如果由于某种原因你想使用echo,你需要做cmd.exe /c echo Whatever。另请注意,检查返回码和输出可能很有用)