Example 1 — Close the Connection
Open a connection, log in, and close it with ftp_quit() when you are done.
<?php
$ftp = ftp_connect('ftp.example.com');
ftp_login($ftp, 'demo', 'secret');
echo "Connected", PHP_EOL;
if (ftp_quit($ftp)) {
echo "Connection closed", PHP_EOL;
} How It Works
- ftp_connect() opens the control connection to the server.
- ftp_login() authenticates with a username and password.
- ftp_quit() sends the quit command and closes the connection.
- It returns true, so the success message is printed.

