Dutch PHP Conference 2025 - Call For Papers

ZipArchive::registerProgressCallback

(PHP >= 8.0.0, PECL zip >= 1.17.0)

ZipArchive::registerProgressCallbackRegister a callback to provide updates during archive close.

Опис

public ZipArchive::registerProgressCallback(float $rate, callable $callback): bool

Register a callback function to provide updates during archive close.

Параметри

rate

Change between each call of the callback (from 0.0 to 1.0).

callback

This function will receive the current state as a float (from 0.0 to 1.0).

Значення, що повертаються

Повертає true у разі успіху або false в разі помилки.

Приклади

This example creates a ZIP file archive php.zip and show progression.

Приклад #1 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();
}

Примітки

Зауваження:

This function is only available if built against libzip ≥ 1.3.0.

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top