PHP installation Php_rar extension to implement RAR file reading and decompression method _php skills

Source: Internet
Author: User
Tags rar

This article illustrates the method of Php_rar extension of PHP installation to realize RAR file reading and decompression. Share to everyone for your reference, specific as follows:

The PHP RAR archiving Module (PHP_RAR) is a module that reads and compresses RAR files, but does not provide a RAR compression (packaging) function.

1. First to download the DLL to PECL's 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 the Windows system, it seems only php5.3/5.4 corresponding DLL download.

2. The download is a ZIP package, which extracts the php_rar.pdb and php_rar.dll two files to the EXT subdirectory under the PHP installation directory.

3. Add a line to the php.ini Php_rar Extension Reference declaration Extension=php_rar.dll

4. If you use the Apache server, you 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 are any problems.

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_open ($archive _name) or Die (' failed to open '. $archive _name);
$entry = Rar_entry_get ($rar, $entry _name) OR die (' failed to find '. $entry _name. ' In '. $archive _name);
This'll create all necessary subdirs under $dir _to_extract_to
$entry->extract ($dir _to_extract_to); 
/* or//This'll create only one one
new file $new _entry_name in $dir _to_extract_to
$entry->extract ("", $dir _to_extract_to. ' /'. $new _entry_name); 
This are really not necessary
rar_close ($rar);
? >

More about PHP Interested readers can view the site topics: "PHP Expanded Development course", "PHP file Operation Summary", "PHP Directory Operation skills Summary", "PHP common traversal algorithm and skills summary", "PHP Array" operation Skills Encyclopedia, " Introductory tutorials for PHP basic syntax, summary of PHP operations and operator usage, summary of PHP string usage, and a summary of PHP common database operations Tips

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.