downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
Last updated: Mon, 16 Jul 2012

CXIII. Rar Functions


Rar is a powerful and effective archiver created by Eugene Roshal. This extension gives you possibility to read Rar archives but doesn't support writing Rar archives, because this is not supported by UnRar library and is directly prohibited by it's license.

More information about Rar and UnRar can be found at




本扩展模块在 php.ini 中未定义任何设置指令。


Rar is currently available through PECL

Also you can use the pear installer to install the Rar extension, using the following command: pear -v install rar.

You can always download the tar.gz package and install Rar by hand:

例子 1. Rar installation

gunzip rar-xxx.tgz
tar -xvf rar-xxx.tar
cd rar-xxx
./configure && make && make install

Windows users can download the extension dll php_rar.dll here:


There is one resource used in Rar extension: a file descriptor returned by rar_open().


RAR_HOST_MSDOS (integer)

RAR_HOST_OS2 (integer)

RAR_HOST_WIN32 (integer)

RAR_HOST_UNIX (integer)

RAR_HOST_BEOS (integer)

例子 2. Rar extension overview example


= rar_open('example.rar') or die("Can't open Rar archive");

$entries = rar_list($rar_file);

foreach (
$entries as $entry) {
'Filename: ' . $entry->getName() . "\n";
'Packed size: ' . $entry->getPackedSize() . "\n";
'Unpacked size: ' . $entry->getUnpackedSize() . "\n";




This example opens a Rar file archive and extracts each entry to the specified directory.

rar_close -- Close Rar archive and free all resources
rar_entry_get -- Get entry object from the Rar archive
Rar::extract -- Extract entry from the archive
Rar::getAttr -- Get attributes of the entry
Rar::getCrc -- Get CRC of the entry
Rar::getFileTime -- Get entry last modification time
Rar::getHostOs -- Get entry host OS
Rar::getMethod -- Get pack method of the entry
Rar::getName -- Get name of the entry
Rar::getPackedSize -- Get packed size of the entry
Rar::getUnpackedSize -- Get unpacked size of the entry
Rar::getVersion -- Get version of the archiver used to add the entry
rar_list -- Get entries list from the Rar archive
rar_open -- Open Rar archive

 Last updated: Mon, 16 Jul 2012
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at:
Last updated: Thu Jul 7 19:13:47 2005 CST