On 10 April 2015 at 00:59, Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:
>
>
> On Apr 9, 2015, at 3:41 PM, Maciek Sokolewicz wrote:
>
>> On 9-4-2015 21:48, Jeffry Killen wrote:
>>>
>>> Hello;
>>>
>>> Is there a reference to explanations of the meanings of the
>>> flags here I have marked with ??:
>>> ZIPARCHIVE::OVERWRITE (I presume this means to remove existing content
>>> and start fresh)
>>> ZIPARCHIVE::CREATE
>>>
>>> ZIPARCHIVE::EXCL ?? (EXCL == exclude(?))
>>>
>>> ZIPARCHIVE::CHECKCONS ??
>>>
>>> There is no explanation in my copy of the manual
>>>
>>> accept what is obvious in the examples given.
>>>
>>> Thanks
>>>
>>> JK
>>
>>
>> Read the only up-to-date version of the manual:
http://www.php.net/manual/en/zip.constants.php
>> (and yes, they're class constants)
>>
>> - Tul
>>
>
> Thank you; very helpful.
>
> It would be nice if there was a full manual on using this alone. I
could google using zip compression or something similar.
>
> So; as I understand it a constant will have an integer associated
> and might be used in a lookup array to get the string value?
>
> I will play around with this to get a feel for it.
>
> Thanks for time and attention
> JK
>
Please reply to the list as well.
The manual actually fully explains how to use them. It states that you
need to supply one of the flags in various functions/methods to get some
desired effect.
For instance:
http://www.php.net/manual/en/ziparchive.open.php
When using ZipArchive::open() it requires up to 2 parameters:
a filename, and an optional flag, which may be one of the following
constants: ZipArchive::OVERWRITE, ZipArchive::CREATE, ZipArchive::EXCL
or ZipArchive::CHECKCONS. Each constant has an integer value. What this
value is exactly, you shouldn't care. Internally, the method wants to
receive an integer; but for you (the developer), it's much easier to
figure out what's going on by using a clear name; so instead you use a
constant.
So when the following is used:
$filename = './archive.zip';
ZipArchive::open($filename, ZipArchive::CREATE);
PHP translates it to:
ZipArchive::open('./archive.zip', 1); // since the value of
ZipArchive::CREATE is some number, for example 1 (I don't know for sure
what it is, this is just for example purposes)
Now, you could of course just write things like:
ZipArchive::open('./archive.zip', 1);
ZipArchive::open('./archive.zip', 3);
but do you now immediately know what's going on here? And what each flag
does? Of course not. So instead we use constants which have a clear name
that tells us what the flag means, and have the corresponding value
(integer):
ZipArchive::open('./archive.zip', ZipArchive::CREATE);
ZipArchive::open('./archive.zip', ZipArchive::OVERWRITE);
The manual itself shows you a ton of examples:
http://www.php.net/manual/en/zip.examples.php and the entire ZipArchive
chapter (http://www.php.net/manual/en/book.zip.php) also contains a ton
of info. No need to google anything, just RTFM (online!).
- Tul
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php