This article describes the PHP installation Php_rar extension implementation of RAR file read and decompression method. Share to everyone for your reference, as follows:
The PHP RAR archiving Module (PHP_RAR) is a module that reads and compresses RAR files, but does not provide RAR compression (packaging) functionality.
1. First to download the DLL to the PECL RAR page. Choose to download the corresponding version of the DLL, depending on your situation.
PHP Version requirements: Php_rar module for PHP 5.2 and above, but for Windows systems, it seems that only the php5.3/5.4 corresponding DLL download.
2. Download to a ZIP package and extract the php_rar.pdb and php_rar.dll two files into the ext subdirectory of the PHP installation directory.
3. Add a row Php_rar extension reference declaration in PHP.ini Extension=php_rar.dll
4. If you use Apache server, you will need to restart Apache. PHP, which is loaded in fastcgi mode under IIS, does not require further action.
5. Write a test file to see if there's a problem.
6. If there is a problem, view the log file for the server.
Attached to the official test code test-rar.php:
<?php$archive_name = '/full/path/to/file.rar ' $entry _name = ' path/to/archive/entry.txt '; Notice:no slash at the beginning$dir_to_extract_to = '/path/to/extract/dir '; $new _entry_name = ' some.txt '; $rar = Rar_op En ($archive _name) or Die ("Failed to open". $archive _name); $entry = Rar_entry_get ($rar, $entry _name) or Die (' failed to fi nd '. $entry _name. ' In '. $archive _name);//This would create all necessary subdirs under $dir _to_extract_to$entry->extract ($dir _to_extract_to ),/* or *///This would create only one new file $new _entry_name in $dir _to_extract_to$entry->extract (", $dir _to_extrac T_to. ' /'. $new _entry_name);//This line was really not necessaryrar_close ($rar);? >