CakeFest 2024: The Official CakePHP Conference

ZipArchive::renameName

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

ZipArchive::renameName名前を使用してエントリ名を変更する

説明

public ZipArchive::renameName(string $name, string $new_name): bool

名前を使用して、エントリ名を変更します。

パラメータ

name

名前を変更するエントリの名前。

new_name

新しい名前。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例1 エントリ名の変更

<?php
$zip
= new ZipArchive;
$res = $zip->open('test.zip');
if (
$res === TRUE) {
$zip->renameName('currentname.txt','newname.txt');
$zip->close();
} else {
echo
'失敗、コード:' . $res;
}
?>
add a note

User Contributed Notes 1 note

up
2
mumpitz89 at gmx dot net
8 years ago
When you rename a file in an archive using the function above and the target file name already exists, the function will return FALSE as a result.
To Top