PHP | zip_entry_close() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 Archive to be broken. The zip entry resource which has to be closed is sent as a parameter to the zip_entry_close() function. Syntax: bool zip_entry_close ( $zip_entry ) Parameters: The zip_entry_close() function accepts single parameter $zip_entry. It is a mandatory parameter which specifies the zip entry resource. Return Value: It returns true on success or False on Failure. Errors And Exceptions: The zip entry archive to be closed must be opened first by using the PHP zip_entry_open() function otherwise the PHP zip_entry_close() function produces a PHP warning. The zip_entry_close() function returns an ER_OPEN error if the zip archive is invalid. The zip_entry_close() function returns an ER_NOZIP error if the zip archive is empty. Suppose a zip file article.zip contains the following file: content.xlsx Below programs illustrate the zip_entry_close() function in PHP: Program 1: php <?php // Opening a zip archive $zip_handle = zip_open("C:/xampp/htdocs/article.zip"); $zip_entry = zip_read($zip_handle); // Opening a zip entry archive zip_entry_open($zip_handle, $zip_entry, "rb"); $file = zip_entry_name($zip_entry); // Closing a zip entry archive $flag = zip_entry_close($zip_entry); if ($flag == true) echo("Zip Entry Archive: " . $file . " has been closed successfully. "); else echo("Zip Entry Archive: " . $file . " cannot be closed."); zip_close($zip_handle); ?> Output: Zip Entry Archive: article/content.xlsx has been closed successfully. Suppose a zip file article.zip contains the following files: content.xlsx gfg.pdf image.jpeg Program 2: php <?php // Opening a zip archive $zip_handle = zip_open("C:/xampp/htdocs/article.zip"); if(is_resource($zip_handle)) { while($zip_entry = zip_read($zip_handle)) { // Opening a zip archive entry $file = zip_entry_open($zip_handle, $zip_entry, "rb"); $file_name = zip_entry_name($zip_entry); if ($file == true) { echo("Zip Entry Archive: " . $file_name . " has been opened successfully." . "<br>"); // Closing a zip archive entry $flag = zip_entry_close($zip_entry); if ($flag == true) echo("Zip Entry Archive: " . $file_name . " has been closed successfully." . "<br>"); else echo("Zip Entry Archive: " . $file_name . " cannot be closed." . "<br>"); } else echo("Zip Entry Cannot be opened."); } // Closing a zip archive zip_close($zip_handle); } else echo("Failed to Open" . $zip_handle ); ?> Output: Zip Entry Archive: article/content.xlsx has been opened successfully. Zip Entry Archive: article/content.xlsx has been closed successfully. Zip Entry Archive: article/gfg.pdf has been opened successfully. Zip Entry Archive: article/gfg.pdf has been closed successfully. Zip Entry Archive: article/image.jpeg has been opened successfully. Zip Entry Archive: article/image.jpeg has been closed successfully. Reference: https://www.php.net/manual/en/function.zip-entry-close.php Comment More infoAdvertise with us Next Article PHP | zip_entry_open() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-file-handling PHP-function +1 More Practice Tags : Misc Similar Reads PHP | zip_close( ) Function 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( 2 min read PHP | zip_entry_compressedsize() Function The zip_entry_compressedsize() function is an inbuilt function in PHP which is used to return the size of the compressed file in zip archive entry. It can be used to retrieve the compressed size of a directory entry. The zip entry resource which has to be read is sent as a parameter to the zip_entry 2 min read PHP | zip_entry_open() Function The zip_entry_open() function is an inbuilt function in PHP which is used to open a zip entry archive for reading. Opening a file or a directory in a zip archive with the zip_entry_open function creates a new stream and establishes a connection between the stream and a file or a directory in a Zip A 3 min read PHP | zip_entry_read() Function The zip_entry_read() function is an inbuilt function in PHP which is used to read the contents from an opened zip archive entry. The zip entry is being read and the number of bytes to be returned can be sent as a parameter to the zip_entry_read() function and it returns the content of the specified 3 min read PHP | zip_entry_name() Function The zip_entry_name() function is an inbuilt function in PHP which is used to return the name of a zip archive entry. The zip entry resource is to be read and sent as a parameter to the zip_entry_name() function and it returns the name of the zip entry archive on Success. Syntax: string zip_entry_nam 2 min read PHP | zip_entry_compressionmethod() Function The zip_entry_compressionmethod() function is an inbuilt function in PHP which is used to return the compression method of a file or a directory from a zip archive entry. The zip entry resource which has to be read is sent as a parameter to the zip_entry_compressionmethod() function and it returns t 2 min read Like