From http://php.net/manual/en/function.exec.php:
You'll need to use an array to get output.
So, use the following code:
$result=[]; // Create an array
exec('your command line', &$result); // Remember the & before the result as it ***IS A REFERENCE***
//DO whatever with your result
The problem is that you didn't pass your result array as a reference.
Or, use shell_exec
, where your return value is everything returned:
$return=shell_exec($command_line);
You can also use backticks:
$result=`cmdline`
Or, use popen(
:
Create a new pointer with:
$handle = popen("/bin/ls", "r");
and then read it:
$read = fread($handle);
and close with:
pclose($handle);
It will block execution until the output stops.