ZipArchive::registerCancelCallback

Register a callback to allow cancellation during archive close.

&reftitle.description; public `bool` `ZipArchive::registerCancelCallback` `callable` `callback`

Register a `callback` function to allow cancellation during archive close.

&reftitle.parameters;

`callback`

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

&reftitle.returnvalues;

&return.success;

&reftitle.examples;

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

### 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();
    }

&reftitle.notes;

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

&reftitle.seealso;

- `ZipArchive::registerProgressCallback`