略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ZipArchive::unchangeIndex

2024-05-01

ZipArchive::unchangeIndex

(PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.1.0)

ZipArchive::unchangeIndexRevert all changes done to an entry at the given index

说明

public ZipArchive::unchangeIndex(int $index): bool

Revert all changes done to an entry at the given index.

参数

index

Index of the entry.

返回值

成功时返回 true, 或者在失败时返回 false

add a noteadd a note

User Contributed Notes 1 note

up
1
till at php dot net
11 years ago
Consider this example:

<?php
$zip
= new ZipArchive;
$zip->open(...);

$zip->addFile('path/file', 'foo');
$zip->renameIndex(0, 'bar');

echo
$zip->getNameIndex(0); // 'bar'

$zip->unchangeIndex(0);

echo
$zip->getNameIndex(0); // 'false'
?>

Unless you call save() in between, the unchangeIndex() call reverts back to the initial state of the archive - where index '0' did not exist.

If you called save() after addFile() and then renamed the file, you would be able to revert/undo the name change.

官方地址:https://www.php.net/manual/en/ziparchive.unchangeindex.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3