ZipArchive::unchangeIndex

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

ZipArchive::unchangeIndex β€” ΠžΡ‚ΠΌΠ΅Π½ΡΠ΅Ρ‚ всС измСнСния Ρƒ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ с Π·Π°Π΄Π°Π½Π½Ρ‹ΠΌ индСксом

ОписаниС

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

ΠžΡ‚ΠΌΠ΅Π½ΡΠ΅Ρ‚ всС измСнСния Ρƒ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ с Π·Π°Π΄Π°Π½Π½Ρ‹ΠΌ индСксом.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

index
ИндСкс ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ.

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Ѐункция Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ true, Ссли Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΠ»Π°ΡΡŒ ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ, ΠΈΠ»ΠΈ false, Ссли Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка.

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 1 note

up
1
till at php dot net ΒΆ
15 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.