Oihana PHP

validateZipStructure.php

Table of Contents

Functions

validateZipStructure()  : bool
Validates the internal structure of a zip file.

Functions

validateZipStructure()

Validates the internal structure of a zip file.

validateZipStructure(string $filePath) : bool

This function checks whether the given file is a valid, readable zip archive. It uses the ZipArchive class to attempt opening the archive and inspects a few entries to confirm structural integrity.

Parameters
$filePath : string

Path to the zip file.

Tags
author

Marc Alcaraz (ekameleon)

since
1.2.0
example
var_dump( validateZipStructure( '/path/to/archive.zip'  ) ); // true or false
var_dump( validateZipStructure( '/path/to/invalid.zip'  ) ); // false
var_dump( validateZipStructure( '/path/to/not_a_zip.txt') ); // false
var_dump( validateZipStructure( '/nonexistent/file.zip' ) ); // false
Return values
bool

True if the file has a valid zip structure, false otherwise.

On this page

Search results