ZipArchive::registerProgressCallback
(PHP >= 8.0.0, PECL zip >= 1.17.0)
Register a callback to provide updates during archive close.
Description
Register a callback function to provide updates during archive close.
Parameters
rateChange between each call of the callback (from 0.0 to 1.0).
callbackThis function will receive the current
stateas afloat(from 0.0 to 1.0).
Return Values
Success
Examples
This example creates a ZIP file archive php.zip and show progression.
Archive a file
$zip = new ZipArchive();
if ($zip->open('php.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
$zip->addFile(PHP_BINARY, 'php');
$zip->registerProgressCallback(0.05, function ($r) {
printf("%d%%\n", $r * 100);
});
$zip->close();
}Notes
This function is only available if built against libzip ≥ 1.3.0.
See Also
ZipArchive::registerCancelCallback