PHP | ftp_close() function Last Updated : 09 Apr, 2019 Comments Improve Suggest changes Like Article Like Report The ftp_close() function is an inbuilt function in PHP which is used to close the already exists FTP connection to a specified FTP server or Host. Syntax: ftp_close( $ftp_connection ); Parameter: This function accepts single parameter $ftp_connection which is required. It specifies the FTP connection to close FTP connection. Return Value: It returns True on success or False on failure. Note: This function is available for PHP 4.0.0 and newer version. The following examples cannot be run on online IDE. So try to run in some PHP hosting server or localhost with proper ftp server name. Below programs illustrate the ftp_close() function in PHP: Example 1: php <?php // Connect to FTP server $ftp_server = "localhost"; // Establishing ftp connection $ftp_connection = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); if($ftp_connection) { echo "Successfully connected to the ftp server!"; // Closing connection if(ftp_close($ftp_connection)) { echo "<br>Connection closed Successfully!"; } } ?> Output: Successfully connected to the ftp server! Connection closed Successfully! Example 2: Connect to ftp server using port 21. php <?php // Connect to FTP server $ftp_server = "localhost"; // Establishing ftp connection $ftp_connection = ftp_connect($ftp_server, 21) or die("Could not connect to $ftp_server"); if($ftp_connection) { echo "Successfully connected to the ftp server!"; // Closing connection if(ftp_close($ftp_connection)) { echo "<br>Connection closed Successfully!"; } } ?> Output: Successfully connected to the ftp server! Connection closed Successfully! Reference:https://www.php.net/manual/en/function.ftp-close.php Comment More infoAdvertise with us Next Article PHP | ftp_close() function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- FTP Similar Reads PHP fclose() Function The fclose() function in PHP closes a file that was previously opened by fopen(). Closing a file releases the resource associated with it and makes sure all the data written to the file is properly saved. Not closing files can lead to resource leaks or incomplete data writing.Syntax:bool fclose(reso 2 min read PHP | ftp_connect() function The ftp_connect() function is an inbuilt function in PHP which is used to create a new connection to the specified FTP server or Host. When connection is successful then only other FTP functions can be run against the server. Syntax:Â ftp_connect( $ftp_host, $ftp_port, $timeout ); Parameter: This fu 2 min read PHP finfo_close() Function The finfo_close() function is an inbuilt function in PHP that is used to close the file instance that is opened by the finfo_open() function. Syntax: finfo_close($finfo):Â boolParameters: This function accepts only one parameter which is described below. $finfo: The file info resource returned by fin 2 min read PHP | ftp_alloc() function The ftp_alloc() function is an inbuilt function in PHP which is used to allocate space for file to be uploaded in FTP server.Syntax:Â Â ftp_alloc( $ftp_connection, $filesize, $result ); Parameter: This function accepts three parameters as mentioned above and described below:Â Â $ftp_connection: It is 3 min read PHP | ftp_delete() function The ftp_delete() function is an inbuilt function in PHP which is used to delete a file on the FTP server. Syntax:Â ftp_delete( $ftp_connection, $file ) Parameters: This function accepts two parameters as mentioned above and described below:Â Â $ftp_connection: It is required parameter. It specifies t 2 min read Like