not seem to getting the outputs from exec() command in PHP, OS: Windows XP
here's the code used: exec("echo %username%",$output);
using print_r($output) which returns 1;
not seem to getting the outputs from exec() command in PHP, OS: Windows XP
here's the code used: exec("echo %username%",$output);
using print_r($output) which returns 1;
echo
is not a program on Windows that you can call. It is a feature provided specifically by the command processor (i.e. cmd.exe
).
If you want the username in this manner don't start up a shell. Use getenv
instead.
(If for some reason you wanted to use echo
you would need to do cmd.exe /c echo Whatever
. Also note that checking the return code as well as the output may be useful)