phpseclib\Net\SFTP::readlink PHP Method

    function readlink($link)
    {
        if (!($this->bitmap & SSH2::MASK_LOGIN)) {
            return false;
        }
        $link = $this->_realpath($link);
        if (!$this->_send_sftp_packet(NET_SFTP_READLINK, pack('Na*', strlen($link), $link))) {
            return false;
        }
        $response = $this->_get_sftp_packet();
        switch ($this->packet_type) {
            case NET_SFTP_NAME:
                break;
            case NET_SFTP_STATUS:
                $this->_logError($response);
                return false;
            default:
                throw new \UnexpectedValueException('Expected SSH_FXP_NAME or SSH_FXP_STATUS');
        }
        if (strlen($response) < 4) {
            return false;
        }
        extract(unpack('Ncount', Strings::shift($response, 4)));
        // the file isn't a symlink
        if (!$count) {
            return false;
        }
        if (strlen($response) < 4) {
            return false;
        }
        extract(unpack('Nlength', Strings::shift($response, 4)));
        return Strings::shift($response, $length);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function readLink($remoteTarget)
 {
     if ($this->isConnected()) {
         return $this->connection->readlink($remoteTarget);
     }
     return false;
 }