title: get result from ssh2_exec
body: <p>I have a script that makes a SSH connection to a server (this works fine). Now I want to execute a command and echo the result I get from this command.</p>
  
  <p>So I do this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$stream = ssh2_exec($conn, 'php -v');
  </code></pre>
  
  <p>but I can't get it to show the response, <code>var_dump</code> returns <code>resource(3) of type (stream)</code>.</p>
  
  <p>I have tried to use:</p>
  
  <pre class="lang-php prettyprint-override"><code>$stream = ssh2_exec($conn, 'php -v');
  $stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
  </code></pre>
  
  <p>but the <code>$stream_out</code> returns an empty string.</p>
  
  <p>So is it possible to print the response as result of the script?</p>