Php check if shell_exec command was successful
<p>I basically want to check if a command ran successfully using <code>shell_exec</code>.</p>
<p>Simple function:</p>
<pre><code>public static function foo()
{
    $command = &quot;blabla&quot;;
    shell_exec($command);
}
</code></pre>
<p>Edit, I tried Mister M's suggestion like this:</p>
<pre><code>foreach($commands as $key =&gt; $value)
{
    shell_exec($value, $output, $return);
}
</code></pre>
<p>And I get this error:</p>
<blockquote>
<p>Undefined variable: output</p>
</blockquote>