PHPverse 2025

Voting

: six minus six?
(Example: nine)

The Note You're Voting On

mlocati at gmail dot com
1 year ago
Since version 0.13 of the SSH2 extension, it's possible to retrieve the command exit status with stream_get_meta_data().

For example:

<?php
$channel
= ssh2_exec($connection, $command);

$metadata = stream_get_meta_data($channel);

$exitCode = $metadata['exit_status'];

?>

Retrieving the exit code is very helpful, since usually, commands return 0 in case of success, and other values in case of errors.

<< Back to user notes page

To Top