PHP Function Reference

PHP ftp_quit() Function



The PHP ftp_quit() function closes the given FTP connection. The function returns true on success or false on failure. This function is an alias of ftp_close() function.

Syntax

ftp_quit(ftp)

Parameters

ftp Required. Specify the FTP connection to close.

Return Value

Returns true on success or false on failure.

Example:

The example below shows the usage of ftp_quit() function.

<?php
//FTP server to use
$ftp_server = "ftp.example.com";
  
//set up a connection or die 
$ftp = ftp_connect($ftp_server)
    or die("Could not connect to $ftp_server");
   
if($ftp) {
  echo "Successfully connected to $ftp_server!\n";
 
  //close the connection
  if(ftp_quit($ftp)) {
    echo "Connection closed successfully!\n"; 
  } 
}
?>

The output of the above code will be:

Successfully connected to ftp.example.com!
Connection closed successfully!

❮ PHP FTP Reference