FtpClient\FtpClient::connect PHP Method

connect() public method

Open a FTP connection.
public connect ( string $host, boolean $ssl = false, integer $port = 21, integer $timeout = 90 ) : FTPClient
$host string
$ssl boolean
$port integer
$timeout integer
return FTPClient
    public function connect($host, $ssl = false, $port = 21, $timeout = 90)
    {
        if ($ssl) {
            $this->conn = @$this->ftp->ssl_connect($host, $port, $timeout);
        } else {
            $this->conn = @$this->ftp->connect($host, $port, $timeout);
        }
        if (!$this->conn) {
            throw new FtpException('Unable to connect');
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 public function __construct($host, $user, $password, $environment)
 {
     $this->connection = new \FtpClient\FtpClient();
     $this->connection->connect($host);
     $this->connection->login($user, $password);
     $this->environment = $environment;
 }