PHP Decompression tar.gz Format file method, _php tutorial

Source: Internet
Author: User
Tags pear php error php online

PHP Decompression tar.gz Format file method,


This article describes the PHP method of extracting tar.gz format files. Share to everyone for your reference, as follows:

1, the use of PHP self-compression and archiving extension (Phar)

$phar = new Phardata (' song.tar.gz ');//The path to extract the file is overwritten $phar->extractto (' c:/tmp ', NULL, true);

2, first need to install Pear class management tools

Linux under

/usr/local/php/bin/pear Install Archive_tar

Wamp default is not installed pear, go-pear.php suitable for the old version, php5.3 need to download Go-pear.phar

Put the downloaded file in the PHP directory (any directory can) execute the PHP go-pear.phar command, according to the prompt to press ENTER

①, installation

#这个类实际安装pear时默认就会安装pear Install Archive_tar

Ii

/** principle: The first 512 bytes of the TAR compression package has its own fixed format, according to these 512 bytes can get the file name of the compressed package, size and other information in conjunction with Gzopen,gzread can decompress GZ format */$tar _object = new Archive_tar (" Song.tar.gz "); $tar _object->extract (' c:/tmp ', true);

3, PHP call external command to perform decompression

Must wait for the command to complete, the script will be launched, the Popen command is not asynchronous to execute error_reporting (e_all); Ini_set ("Display_errors", 1); $handle = Popen ("TAR-XZVF Song.tar.gz 2>&1 ", ' R ');/*while (!feof ($handle)) {set_time_limit (3);  $buffer = fgets ($handle);  echo "$buffer \ n";  Ob_flush ();  Flush ();} */echo "Start \ n";p close ($handle); echo "End \ n";

More about PHP related content readers can view the topic: "PHP operation zip file and compression skills summary", "PHP Basic Grammar Introductory Tutorial", "PHP error and Exception handling method summary" and "PHP common functions and Skills summary"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • PHP decompression file code for PHP online decompression
    • PHP Implementation zip file decompression operation
    • PHP uses ziparchive function to implement file compression and decompression
    • PHP Online Decompression zip file method
    • PHP implementation Zip Compressed file extract code sharing (easy to understand)
    • How to extract RAR files and zip files from php
    • A small example of PHP processing files (unzip, delete directories)
    • PHP zip file Decompression Class code
    • PHP zlib compression and decompression of SWF file code
    • PHP for gzip file or string decompression instance reference

http://www.bkjia.com/PHPjc/1099065.html www.bkjia.com true http://www.bkjia.com/PHPjc/1099065.html techarticle PHP Decompression tar.gz Format File method, this article describes the PHP decompression tar.gz format file method. Share to everyone for reference, as follows: 1, the use of PHP self-compression and archiving ...

  • 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.