Zip support with zlib

Hi there,

I’m running php 5.2.15 on an apache server, and I want to be able to open and read zip archives with php.

Phpinfo is telling me that zlib is enabled:

‘–with-zlib=/usr’ ‘–with-zlib-dir=/usr’ (Yes, it does appear twice)

but I don’t think I installed it, unless it ships with this release of php.

I have tried to use ZipArchive and zip->open commands and I’m not getting any joy. So I guess two questions arise. 1. Is there anyway of finding out for sure if zlib is actually installed, and 2. Could the --with-zlib command actually be pointing to the wrong folder? I guess the directory should be where the library is stored, rather than where my php files are…?

Many thanks,
Mike

This will tell you if it is available.


<?php
printf(
  'Is ZipArchive Available? %s',
  class_exists('ZipArchive') ? 'Yes :)' : 'No :('
);

Thanks Anthony, a very elegant code snippet.

It appears I do have ZipArchive support! Whoo-hoo! I guess it was because i was running functions directly form the command-line…?

Anyways, thanks for your help. Much appreciated.
M