Can you return false from the contructor?
<?php
class ftp_stfp{
//private vars of the class
private $host;
private $username;
private $password;
private $connection_type;
private $connection = false;
function __contruct( $host, $username, $password, $connection_type ){
//setting the classes vars
$this->host = $host;
$this->username = $username;
$this->password = $password;
$this->connection_type = $connection_type;
//now set the connection into this classes connection
$this->connection = $this->connect();
//check the connection was set else return false
if($this->connection === false){
return false;
}
} ... etc etc the rest of the class
Call the class:
$ftp_sftp = new ftp_sftp( $host, $uname, $pword, $connection_type );
Is this actually correct, ie would the $ftp_sftp var either be false or hold the class depending on outcome of the __construct method, or is this completely wrong logic?