So to output the result of a command executed by ssh2_exec you should use following code setup
$stream = ssh2_exec($conn,'php -v');
stream_set_blocking($stream,true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
echo stream_get_contents($stream_out);
Creds: http://stackoverflow.com/questions/12086474/get-result-from-ssh2-exec