<?php $rar_arch = RarArchive::open('filename.rar'); if ($rar_arch === FALSE)
die("Failed opening file");
$entries = $rar_arch->getEntries(); if ($entries === FALSE)
die("Failed fetching entries");
echo "Found " . count($entries) . " extract'location";
if (empty($entries))
die("No valid entries found.");
$stream = reset($entries)->getStream();
if ($stream === FALSE)
die("Failed opening first file");
$rar_arch->close();
echo "Content of first one follows:'n";
echo stream_get_contents($stream);
fclose($stream); ?>
http://php.net/manual/en/rar.installation.php 错误是:
Fatal error: Class 'RarArchive' not found in C:'Zend'Apache2'htdocs'CSV'example.php on line 2
这里有windows二进制文件:http://pecl.php.net/package/rar
如果你打开你提供的链接,然后点击"http://pecl.php.net/package/rar"链接在第一行你得到那个页面。
之后,将.dll
放到php扩展目录中,并添加
extension=php_rar.dll
到你的php.ini
PS:我假设.dll
的名称是php_rar.dll
。将其相应更改为在下载的归档文件中分发的内容。
除了下载正确的dll并将其放入ext文件夹,在php.ini中配置它之外,您还必须安装PEAR
。
PHP_RAR依赖于PEAR。有关更多信息,请参阅此。你可以按照这个链接安装PEAR。
如果您在windows中安装pear,请记住使用具有管理员权限的命令行工具。