<?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
答案 0 :(得分:0)
这里有windows二进制文件:http://pecl.php.net/package/rar
如果您打开您提供的链接,请点击您获得该页面的第一行中的“http://pecl.php.net/package/rar”链接。
之后将.dll
放到你的php扩展名dir并放行
extension=php_rar.dll
到php.ini
PS:我假设.dll
的名称是php_rar.dll
。相应地将其更改为下载的存档中分发的内容。
答案 1 :(得分:0)