简体   繁体   English

ZipArchive php类 - 它内置于PHP吗?

[英]ZipArchive php Class - Is it built-in to PHP?

Ok, just wondering on the versions of PHP that this class is built into. 好的,只是想知道这个类内置的PHP版本。 And if they are built into all platforms (OS's). 如果它们内置于所有平台(OS)。 I'm wanting an approach to search through a zip file and place files using file_put_contents in different filepaths within the webroot. 我想要一种搜索​​zip文件的方法,并使用file_put_contents将文件放在webroot中的不同文件路径中。 In any case, I'm familiar with how to do this with the ZipArchive class, but I'm wondering if using this class would be a good solution and support MOST, if not ALL servers?? 在任何情况下,我都熟悉如何使用ZipArchive类,但我想知道使用这个类是否是一个很好的解决方案并支持MOST,如果不是所有服务器? I mean, I'd rather not use a method that requires the Server to have it installed. 我的意思是,我宁愿不使用需要服务器安装它的方法。 I'm looking for a solution to this that will support at least MOST servers without having to install the class... 我正在寻找一个解决方案,至少支持MOST服务器,而无需安装类...

Thanks :) 谢谢 :)

Also, I'd like to support opening tar.gz and/or .tgz files if possible, but I don't think the ZipArchive class supports this, but perhaps a different built-in php class does?? 另外,如果可能的话,我想支持打开tar.gz和/或.tgz文件,但我不认为ZipArchive类支持这个,但是可能有一个不同的内置php类呢?

Tar support is not built into PHP, but if you have a look at the PEAR library you should be able to find some classes that support creating/extracting tarballs (amongst others). tar支持不是内置于PHP中,但如果您查看PEAR库,您应该能够找到一些支持创建/提取tarball的类(以及其他类)。 Have a look at http://pear.php.net/package/Archive_Tar or http://pear.php.net/package/File_Archive . 请查看http://pear.php.net/package/Archive_Tarhttp://pear.php.net/package/File_Archive The last one should be a generic interface to multiple archiving formats (including ZIP and TAR). 最后一个应该是多种归档格式(包括ZIP和TAR)的通用接口。

Whether or not ZIP support is built-in may vary, though I guess most packagers will include it. 是否内置ZIP支持可能会有所不同,但我猜大多数包装商都会包含它。 Then again, you could always test it by checking if the ZipArchive class exists by calling class_exists('ZipArchive'); 然后,您可以通过调用class_exists('ZipArchive');检查ZipArchive类是否存在来测试它class_exists('ZipArchive'); and show a nice error message or fall back to a more generic approach... 并显示一个很好的错误消息或回退到更通用的方法...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM