Example:
If you run a simple command like cc at the command prompt, you would get the output as following
$ cc
i686-apple-darwin10-gcc-4.2.1: no input files
$
If u run the same command using PHP exec command $cmd = "cc";
exec($cmd,$out);
print_r($out);
The output would be and empty array: Array ( )
So, In order to get the error string as well, we need to append 2>&1 $cmd = "cc 2>&1";
exec($cmd,$out);
print_r($out);
The output will print: Array ( [0] => i686-apple-darwin10-gcc-4.2.1: no input files )