【发布时间】:2011-10-29 02:44:07
【问题描述】:
似乎没有从 PHP 中的 exec() 命令获取输出,操作系统:Windows XP
这是使用的代码: exec("echo %username%",$output);
使用 print_r($output) 返回 1;
【问题讨论】:
似乎没有从 PHP 中的 exec() 命令获取输出,操作系统:Windows XP
这是使用的代码: exec("echo %username%",$output);
使用 print_r($output) 返回 1;
【问题讨论】:
echo 不是 Windows 上可以调用的程序。这是命令处理器专门提供的功能(即cmd.exe)。
如果您希望以这种方式使用用户名,请不要启动 shell。请改用getenv。
(如果出于某种原因您想使用echo,则需要使用cmd.exe /c echo Whatever。还要注意检查返回码和输出可能会有用)
【讨论】: