PHP Reference

Quick Reference

The PHP ftp_ssl_connect() function opens a secure SSL-FTP connection. Once the connection is open, FTP functions can be run against the server.

Note

This function is only available if both the ftp module and the OpenSSL support is built statically into PHP.

<?php
// set up basic SSL connection
$ftp_server = '123.123.123.123';
$ftp_conn = ftp_ssl_connect($ftp_server) or die('Could not connect to server');

// login
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

// do something...

// close connection
ftp_close($ftp_conn);
?>

Output

// opens a secure SSL-FTP connection

Syntax

ftp_ssl_connect(host, port, timeout)

Parameters

ParameterDescription
hostSpecifies the FTP server address (a domain address or an IP address and should not be prefixed with "ftp://" or have any trailing slashes) (required)
portSpecifies the port to connect to (default is 21)
timeoutSpecifies the timeout for network operations (default is 90 seconds)

PHP Notes:

  • When using PHP, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
  • Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.