I use PHP in Windows 11. I need to execute multiple commands in PHP exec.
My sample code is as follows:
$output=null;
$result_code=null;
exec("cd E:/Python/WordFrequency ; ipconfig", $output, $result_code);
return $result_code;
The return error code is 1.
However, if only one command is executed, it can work normally:
exec("cd E:/Python/WordFrequency", $output, $result_code);
Or:
exec("ipconfig", $output, $result_code);
Return codes are all 0.
However, if the two commands are concatenated, code 1 will be returned.
I have tried ";" Replace with "&&", and/or set the command with escapeshellcmd or escapeshellarg, as follows:
exec(escapeshellcmd("cd E:/Python/WordFrequency ; ipconfig"), $output, $result_code);
But the result is the same, and the error code 1 is returned.
What's the matter, please?