phpphpseclibnet-sftp

Using phpseclib to close a Net_SFTP connection


I have a program written in PHP that distributes files to various FTP sites. Recently, I added SFTP support to it using phpseclib. It's very easy to use to log in and upload the files.

However, there doesn't seem to be an explicit function to close a connection. This is important to me because I'm dealing with connecting /disconnecting to a number of sites during the processing.

How can I close a Net_SFTP connection?


Solution

  • Does undefining your connection work (as mentioned in this PerlĀ 5 example)?

    unset($sftp);  
    

    where $sftp is the variable holding your connection.