What function can be used in PHP to establish an FTP connection to a server?

To establish an FTP connection to a server in PHP, you can use the `ftp_connect()` function. This function creates an FTP connection to the specified server. You can then use this connection to perform various FTP operations such as uploading files, downloading files, creating directories, etc.

// FTP server credentials
$ftp_server = 'ftp.example.com';
$ftp_username = 'username';
$ftp_password = 'password';

// Establish FTP connection
$ftp_connection = ftp_connect($ftp_server);

if ($ftp_connection) {
    // Login to FTP server
    $login = ftp_login($ftp_connection, $ftp_username, $ftp_password);

    if ($login) {
        echo 'Connected to FTP server and logged in successfully.';
    } else {
        echo 'Failed to login to FTP server.';
    }
} else {
    echo 'Failed to connect to FTP server.';
}