Reputation: 18881
I've found many ways to run a command, like exec
,system
,shell_exec
, but they all seem to return the command output.
I want only the return value (integer).
How can I do that?
<?php
$retval = something("script.sh");
Upvotes: 0
Views: 656
Reputation: 158090
You can use exec()
exec("command", $output, $retval);
echo "output: $output\n";
echo "return value: $retval\n";
exec()
consumes $output
and $retval
by reference and their values will be set inside of exec()
. Check the manual of exec()
again.
Btw, $output
and $retval
will get implicitly initialized, they don't need to exist before the exec()
call.
Upvotes: 2