PHP 8.4.1 Released!

ZipArchive::registerCancelCallback

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

ZipArchive::registerCancelCallbackRegister a callback to allow cancellation during archive close.

Опис

public ZipArchive::registerCancelCallback(callable $callback): bool

Register a callback function to allow cancellation during archive close.

Параметри

callback

If this function return 0 operation will continue, other value it will be cancelled.

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

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

Приклади

This example creates a ZIP file archive php.zip and cancel operation on some run condition.

Приклад #1 Archive a file

<?php
$zip
= new ZipArchive();
if (
$zip->open('php.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
$zip->addFile(PHP_BINARY, 'php');
$zip->registerCancelCallback(function () {
return (
$someruncondition ? -1 : 0);
});
$zip->close();
}

Примітки

Зауваження:

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

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

add a note

User Contributed Notes

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