Contents

PHP exec Return Error Messages

exec

exec
This function is for executing OS command in PHP.

exec Error

1
exec('none-exist-command', $output, $exit);
Imporant
Above the command none-exist-command occurs an error because it’s not exist command.
IMPORTANT!!
Maybe you think you can get error messages from the $output.
BUT IT’S NOT!!

Return Error Messages

1
exec('none-exist-command 2>&1', $output, $exit);
2>&1
If you want to get error messages, you have to append 2>@1 option the command.