PHP.mk документација

ZipArchive::close

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

ziparchive.close.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека ziparchive.close.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
ZipArchive::close

Референца за `ziparchive.close.php` со подобрена типографија и навигација.

ziparchive.close.php

ZipArchive::close

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

ZipArchive::closeClose the active archive (opened or newly created)

= NULL

public ZipArchive::close(): bool

Затвори ја активната архива (отворена или новосоздадена)

Затвори ја отворената или новосоздадената архива и зачувај ги промените. Овој метод автоматски се повикува на крајот од скриптата. ZipArchive::AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE Ако архивата не содржи никакви датотеки, датотеката целосно се отстранува по дифолт (не се запишува празна архива) според вредноста на

Параметри

Оваа функција нема параметри.

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true на успех или false при неуспех.

Види Исто така

Белешки од корисници 8 белешки

глобалниот флаг.
пред 16 години
It may seem a little obvious to some but it was an oversight on my behalf.

If you are adding files to the zip file that you want to be deleted make sure you delete AFTER you call the close() function.

If the files added to the object aren't available at save time the zip file will not be created.
jared at kippage dot com
пред 15 години
If you're adding multiple files to a zip and your $zip->close() call is returning FALSE, ensure that all the files you added actually exist. Apparently $zip->addFile() returns TRUE even if the file doesn't actually exist. It's a good idea to check each file with file_exists() or is_readable() before calling $zip->addFile() on it.
john factorial
пред 9 години
ZipArchive.close() changes its behaviour in PHP7. The function ignores directories in PHP5 but fails in PHP7 with: 

Unexpected PHP error [ZipArchive::close(): Read error: Is a directory]

The following code works in PHP5 but not in PHP7:

<?php 
// test.php
$zip = new ZipArchive();
$zip->open('/tmp/test.zip', ZipArchive::CREATE);
$zip->addFile('.', '.');
$ret = $zip->close();
echo "Closed with: " . ($ret ? "true" : "false") . "\n";
?>

For php5:

php --version
  PHP 5.5.38-1-avature-ondrej-fork (cli) (built: Aug 31 2016 16:37:38)

php test.php
  Closed with: true

For php7:

php --version
  PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )

php test.php
  Closed with: false
javier dot santacruz at avature dot net
пред 14 години
If you have created a zip file and added a file to it without error, yet the ZipArchive::close call fails (with ER_TMPOPEN: "Failure to create temporary file") and the zip file is not created, check to see if your ZipArchive::open call specifies a pathname containing nonexisting directories. If you expect a containing hierarchy of one or more directories, you must create them yourself before using using ZipArchive. You can write a simple function to recurse using dirname to find each parent directory, creating those that don't exist by using mkdir when leaving the recursion.
luciandex
пред 4 години
I am not sure, but seems that $zip->close() can run into errors if the path specified in $zip->open is a relative path, not absolute.
So, when create archives, please specify ABSOLUTE PATH, not relative path for zip file to be created.
m021 at springtimesoftware dot com
пред 18 години
Don't forget to check the zip isn't empty, folks - otherwise the zip won't be created at all, and the server will issue no warning!

I used a certain loop to add files to the zip, and struggled with permissions and documentation for hours before I realize the loop ended up adding no file, even though addFile WAS called, but on a non-existent file.
This might be the reason your zips aren't popping up.
gilthans at gmail dot com
3 години пред
If you get an error like "ZipArchive::close(): Renaming temporary file failed: Permission denied" at random times, check your antivirus software (e.g. Trellix), which may block writing while scanning the file. In my case, I had to check with flock until file is unlocked.
Clemens
пред 11 години
Pay attention, that ZipArchive::addFile() only opens file descriptor and does not compress it. And only ZipArchive::close() compress file and it take quite a lot of time. Be careful with timeouts.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.