PHP file extraction function details

Source: Internet
Author: User
PHP decompression file functions to use this function library requires the first installation of zlib, to the http://www.zlib.net/to obtain the function library. )

Zclose: close the compressed file.

Gzeof: determines whether the file is at the end of the compressed file.

Gzfile: Read the compressed file to the array.

Gzgetc: read the characters in the compressed file.

Gzgets: the string in the compressed file.

Gzgetss: Read the string in the compressed file and remove the HTML command.

Gzopen: Open the compressed file.

Gzpassthru: extract all data after the pointer is decompressed.

Gzputs: data is written into a compressed file.

Gzread: reads a specified length string from a compressed file.

Gzrewind: reset the pointer to the compressed file.

Gzseek: Set the pointer of the compressed file to a specified position.

Gztell: Get the pointer of the compressed file.

Readgzfile: reads compressed files.

Gzwrite: write data into a compressed file.

Gzclose closes the compressed file.

Syntax: boolean gzclose (int zp );

Return value: Boolean

Function type: special file format

Description: This function disables opened compressed files. The zp parameter is the pointer code of the compressed file. If the call succeeds, the return value is true.

Reference: gzopen ()

Gzeof determines whether the file is at the end of the compressed file.


Syntax: boolean gzeof (int zp );

Return value: Boolean

Function type: special file format

Description: This function is used to determine whether the currently opened compressed File pointer points to the End OF the File (EOF, End OF File ). The zp parameter is the pointer code of the compressed file. Returns true at the end of the file.

Gzfile reads compressed files into arrays.

Syntax: array gzfile (string filename );

Returned value: Array

Function type: special file format


Description: This function reads the compressed file and decompress it to an array variable. The filename parameter is the file name.

Gzgetc reads the characters in the compressed file.

Syntax: string gzgetc (int zp );

Return value: string


Function type: special file format

Description: This function decompress the compressed file and extract one character. The parameter gz is the compressed file opening code. If it is at the end of the file, false is returned.

Gzgets reads the string in the compressed file.

Syntax: string gzgets (int zp, int length );

Return value: string

Function type: special file format

Description: This function decompress the compressed file and extract the string of the specified length. The parameter gz is the compressed file opening code. The parameter length is the length of the specified string plus one, that is, the length of the read string is length-1. If a row stops at the end of a file or at the end of a row, this function is usually used to read a row.

Gzgetss reads the string in the compressed file and removes the HTML command.

Syntax: string gzgetss (int zp, int length );

Return value: string

Function type: special file format

Content Description: This function decompress the compressed file and extract the string of the specified length, and remove the HTML or PHP commands in the string to return pure text. The parameter gz is the compressed file opening code. The parameter length is the length of the specified string plus one, that is, the length of the read string is length-1. If a row stops at the end of a file or at the end of a row, this function is usually used to read a row.

Gzopen open the compressed file.

Syntax: int gzopen (string filename, string mode );

Return value: integer

Function type: special file format

Description: This function is used to open a compressed file. The filename parameter is the file name. The parameter mode is the status of the open file. If any failure occurs, false is returned.

Examples:

$ Fp = gzopen ("/tmp/gzfile.gz", "r ");

?>

Refer to gzclose ()

All data after gzpassthru decompress the pointer.

Syntax: boolean gzpassthru (int zp );

Return value: Boolean


Function type: special file format

Content Description: This function decompress all the data after the pointer to the compressed file is opened, and output it to the standard output device (stdout ). The parameter gz is the code for opening a file. If any failure occurs, false is returned.

Gzputs data is written into a compressed file.

Syntax: boolean gzputs (int zp, string str, int [length]);

Return value: Boolean

Function type: special file format

Description: This function is actually gzwrite (). The parameter gz is the code for opening a file. The str parameter is the string to be written. The length parameter can be omitted, which is the specified length. If any failure occurs, false is returned.

Read the specified length string from the gzread compressed file. Syntax: string gzread (int zp, int length); return value: string function type: special File Format Description: This function is used to read a string of the specified length. The parameter gz is the code for opening a file. The length parameter is the specified length. Example
 

Gzrewind resets the pointer to the compressed file.

Syntax: boolean gzrewind (int zp );

Return value: Boolean

Function type: special file format

Description: This function resets the operation pointer of the compressed file to the file header. The zp parameter is the open file code.

Gzseek sets the pointer of the compressed file to a specified position.

Syntax: int gzseek (int zp, int offset );

Return value: integer


Function type: special file format

Description: This function resets the operation pointer of the compressed file to the specified location. The zp parameter is the open file code. The offset parameter is the nth digit. If the call succeeds, 0 is returned. if the call fails,-1 is returned.

Gztell gets the pointer of the compressed file. Syntax: int gztell (int zp); return value: integer function type: special File Format Description: This function is used to obtain the file operation pointer of a compressed file somewhere. The zp parameter is the open file code. Example
 

Readgzfile reads compressed files

Syntax: boolean readgzfile (string filename );

Return value: Boolean

Function type: special file format

Description: This function reads and decompress all compressed files, and sends the content to the stdout device ). The filename parameter is the file name. This function can also read non-compressed files to the standard output device.

Gzwrite data is written into a compressed file.

Syntax: boolean gzwrite (int zp, string, int [length]);

Return value: Boolean

Function type: special file format

Description: This function is used to write data to a specified compressed file. The parameter gz is the code for opening a file. The str parameter is the string to be written. The length parameter can be omitted, which is the specified length. If any failure occurs, false is returned.


Attaches the PHP zip file function Source code:

/********************** @ File-path to zip file the path of the file to be decompressed * @ destination -destination directory for unzipped files, make sure that this extension has enabled */function unzip_file ($ file, $ destination) {// instantiate object $ zip = new ZipArchive (); // open the zip file, if it fails to be opened, a prompt message is returned. if ($ zip-> open ($ file )! = TRUE) {die ("cocould not open archive");} // decompress the compressed file to the specified directory $ zip-> extracation ($ destination ); // close the zip file $ zip-> close (); echo 'archiveextracted to directory';} // test execution // unzip_file ("1.func.zip", "1 ");
Thank you for following the websites blog!

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.