Is it possible to get the error text at the output of the exec() function, and not the code?
Example:
cat: /file_path No such file or directory It is possible, but for this, use the shell_exec function.
It returns the full output as a string, which is what you need.
You just need to add 2>&1 to output data to a variable:
$output = shell_exec("cat /home 2>&1"); var_dump($output); The output will be:
string(27) "cat: /home: Is a directory" Source: https://ru.stackoverflow.com/questions/683832/
All Articles