Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ftp {
- private $host, $user, $pass, $port;
- function __construct($host, $user, $pass, $port = null) {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->port = $port;
- }
- private function connectIfNeeded(){
- if($this->connection){ return; }
- $this->connection = ftp_connect(.........);
- }
- function __destruct(){
- if($this->connection){
- ftp_close($this->connection);
- }
- }
- function getCWD(){
- $this->connectIfNeeded();
- // ...
- }
- function listFiles(){
- $this->connectIfNeeded();
- // ...
- }
- function getFile($file){
- $this->connectIfNeeded();
- // ...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement