title: phplibsec - loop login until connected
body: <p>I would like to continue trying to connect to a remote server using the phplibsec package until the connection = true ... there is a standard code for what to do if it doesn't connect, but I rather check it over and over until it connects. I initially tried this code snippet below where if it gets to 5 attempts, it stops and says too many, but it just keeps not connecting. However, when I attempt to connect to it (in one line) and send a command, it works just fine.</p>
  
  <pre><code>$attempts = 0;
  while (true) {
      if (!$sftp-&gt;login('user', 'pass')) {
          echo "unable to connect." . PHP_EOL;
          $attempt += 1;
          echo "Attempts: ".$attempts;
          continue;
      } else if ($attempts = 5) {
          echo "5 attempts, check user/password/ip";
          break;
      } else {
          break;
      }
  }
  </code></pre>