To use this library, you will need to install zlib first, and you can get to http://www.zlib.net/the library. )
Zclose: Closes the compressed file.
Gzeof: Determines whether the end of the file is compressed.
Gzfile: Reads the compressed file into the array.
Gzgetc: Reads the characters in the compressed file.
Gzgets: Reads a string from a compressed file.
GZGETSS: Reads the string in the compressed file and removes the HTML instruction.
Gzopen: Open the compressed file.
Gzpassthru: Unzip all the data after the pointer.
Gzputs: Data is written to the compressed file.
Gzread: Compressed file reads out the specified length string.
Gzrewind: Resets the compressed file pointer.
Gzseek: Set the compressed file pointer to the specified place.
Gztell: Gets the compressed file pointer.
Readgzfile: read out the compressed file.
Gzwrite: Data is written to the compressed file.
Gzclose close the compressed file.
Syntax: boolean gzclose (int ZP);
Return Value: Boolean value
Function type: Special file format
Description: This function closes the compressed file that has been opened. The parameter ZP is the pointer code for the compressed file. Success returns a true value.
Reference: Gzopen ()
Gzeof determines if the end of the file is compressed.
Syntax: boolean gzeof (int ZP);
Return Value: Boolean value
Function type: Special file format
Description: This function is used to determine whether the currently opened compressed file pointer refers to the end of the file (EOF, end of file). The parameter ZP is the pointer code for the compressed file. Returns a true value at the end of the file.
Gzfile reads the compressed file into the array.
Syntax: Array gzfile (string filename);
return value: Array
Function type: Special file format
Description: This function reads the compressed file and unzip it into the array variable. The parameter filename 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 extracts the compressed file and extracts one character. Parameter GZ opens the code for the compressed file. Returns false to the end of the file.
Gzgets reads a string in a compressed file.
Syntax: string gzgets (int ZP, int length);
return value: String
Function type: Special file format
Description: This function extracts the compressed file and extracts the string of the specified length. Parameter GZ opens the code for the compressed file. Parameter length is the length of the specified string plus one, meaning that the read-out string is length-1. This function is typically used to read a line if it stops at the end of the file or at the end of the line.
Gzgetss reads the string in the compressed file and removes the HTML instruction.
Syntax: string gzgetss (int ZP, int length);
return value: String
Function type: Special file format
Description: This function extracts the compressed file and extracts the string of the specified length and removes the HTML or PHP instruction from the string, returning plain text. Parameter GZ opens the code for the compressed file. Parameter length is the length of the specified string plus one, meaning that the read-out string is length-1. This function is typically used to read a line if it stops at the end of the file or at the end of the line.
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 parameter filename is the file name. The parameter mode is the state of the open file. Returns the false value if there is a failure.
Use example, below are some programs
$FP =gzopen ("/tmp/gzfile.gz", "R");
?>
Reference Gzclose ()
Gzpassthru all data after extracting the pointer.
Syntax: boolean gzpassthru (int ZP);
Return Value: Boolean value
Function type: Special file format
Description: This function will unzip the data after opening the file pointer of the compressed file, and output to the standard output device (STDOUT). The parameter GZ is the code that opens the file. Returns the false value if there is a failure.
Gzputs data is written to the compressed file.
Syntax: boolean gzputs (int ZP, string str, int [length]);
Return Value: Boolean value
Function type: Special file format
Description: This function is actually gzwrite (). The parameter GZ is the code that opens the file. The parameter str is the string to write. Parameter length can be omitted, for the specified lengths. Returns the false value if there is a failure.
Gzread a compressed file to read out the specified length string. Syntax: string gzread (int ZP, int length); return value: String function type: Special file Format Content Description: This function is used to read a string of a specified length. The parameter GZ is the code that opens the file. The length of the parameter is specified. Usage examples
Gzrewind resets the compressed file pointer.
Syntax: boolean gzrewind (int ZP);
Return Value: Boolean value
Function type: Special file format
Description: This function resets the file operation pointer of the compressed file to the file header. The parameter ZP is the open file code.
Gzseek set the compressed file pointer to the specified place.
Syntax: int gzseek (int ZP, int offset);
return value: Integer
Function type: Special file format
Description: This function resets the file operation pointer of the compressed file to the specified bit. The parameter ZP is the open file code. The parameter offset is the first digit. The success returns 0, and the failure returns-1.
Gztell Gets the compressed file pointer. Syntax: int gztell (int zp); return value: Integer function type: Special file Format Content Description: This function is used to get the file operation pointer of the compressed file at a certain place. The parameter ZP is the open file code. Usage examples
Readgzfile read out the compressed file
Syntax: Boolean readgzfile (string filename);
Return Value: Boolean value
Function type: Special file format
Description: This function reads and decompress all compressed files and then sends the contents to the standard output device (STDOUT). The parameter filename is the file name. This function can actually read non-compressed files to the standard output device.
Gzwrite data is written to the compressed file.
Syntax: boolean gzwrite (int ZP, string string, int [length]);
Return Value: Boolean value
Function type: Special file format
Description: This function is used to write data to the specified compressed file. The parameter GZ is the code that opens the file. The parameter str is the string to write. Parameter length can be omitted, for the specified lengths. Returns the false value if there is a failure.
The source code is attached to the PHP decompression zip file function:
/********************** * @file-path to zip file path to the extracted files * @destination-destination directory for unzipped files< c1/> the path stored after decompression * @Recorded by Androidyue *@ need to use the Zziplib Library, please confirm that the extension has been turned on * /function Unzip_file ($file, $ Destination) { //instanced object $zip = new ziparchive (); Open the Zip document if open fails to return the prompt if ($zip->open ($file)!== TRUE) {die ("Could not open Archive"); } Unzip the compressed file into the specified directory $zip->extractto ($destination); Close the zip document $zip->close (); Echo ' Archive extracted to directory '; } Test execution //unzip_file ("1.func.zip", "1");
Thank you for your attention websites blog!