PHP | zip_close( ) Function Last Updated : 17 Jul, 2018 Comments Improve Suggest changes Like Article Like Report The zip_close() function is an inbuilt function in PHP which is used to close a zip archive file opened by the zip_open() function. The zip_close() causes the stream to be closed and the connection to the corresponding Zip Archive to be broken. The zip resource which has been opened by the zip_open() function is sent as a parameter to the zip_close() function and it returns no value. Syntax: void zip_close ( $zip_file ) Parameters: The zip_close() function accepts single parameter $zip_file. It is a mandatory parameter which specifies the zip file resource to be closed. Return Value: It does not return any value. Errors And Exceptions: The zip Archive to be closed must be opened first by using the PHP zip_open() function otherwise the PHP zip_close() function produces a PHP warning. The zip_close() function returns an ER_OPEN error if the zip archive is invalid. The zip_close() function returns an ER_NOZIP error if the zip archive is empty. Below programs illustrate the zip_close() function in PHP: Program 1: php <?php // Opening zip archive's file $zip_file = zip_open("article.zip"); if(is_resource($zip_file)) { echo("Zip Archive File is Successfully Opened."); // Closing zip archive's handle zip_close($zip_file); } else { echo($zip_file . " Archive File Cannot Be Opened"); } ?> Output: Zip Archive File is Successfully Opened. Program 2: php <?php // Opening zip archive's file $zip_file = zip_open("article.zip"); if(is_resource($zip_file)) { while($zipfiles = zip_read($zip_file)) { $file_name = zip_entry_name($zipfiles); echo("File Name: " . $file_name . "<br>"); } // Closing zip archive's zip_close($zip_file); } else { echo($zip_file . " Archive File Cannot Be Opened"); } ?> Output: File Name: article/content.xlsx File Name: article/gfg.pdf File Name: article/image.jpeg Reference : http://php.net/manual/en/function.zip-close.php Comment More infoAdvertise with us Next Article PHP | zip_close( ) Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-file-handling Practice Tags : Misc Similar Reads PHP | zip_entry_close() Function The zip_entry_close() function is an inbuilt function in PHP which is used to close a zip archive opened by the zip_entry_open() function. The zip_entry_close() causes the stream to be closed and the connection to the corresponding Zip Archive Entry which may be a file or a directory within the Zip 3 min read 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 ZipArchive close() Function The PHP ZipArchive::close() function is an inbuilt function in PHP that is used to close the opened archive file and save the changes. This function is called after performing all operations on the zip file. If the zip archive does not contain any file then by default zip file is deleted.Syntax:bool 2 min read PHP | closedir( ) Function The closedir() function in PHP is an inbuilt function which is used to close a directory handle. The directory handle to be closed is sent as a parameter to the closedir() function and the closedir() closes the directory handle. The directory handle must be previously opened by the opendir() functio 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 Like