Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

// send the entire file to browser
gzpassthru($myFile);
?>


boolean gzputs(int file_handle, string output, integer length)


The gzputs function writes data to a compressed file. It expects a file handle as returned
by gzopen. It returns TRUE if the write was successful, FALSE if it failed. The optional
length argument specifies a maximum number of input bytes to accept. A side effect of
specifying length is that the magic_ quotes_runtime configuration setting will be
ignored.


<?
// open file for writing
// use maximum compress and force
// Huffman encoding only
$myFile = gzopen("data.gz","wb9h");


// make sure the open was successful
if(!($myFile))
{
print("file could not be opened");
exit;
}


for($index=0; $index<10; $index++)
{
// write a line to the file
gzputs($myFile, "line $index\n");
}


// close the file
gzclose($myFile);
?>


gzread


The gzread function is an alias to gzgets.


boolean gzrewind(integer file_handle)


The gzrewind function moves PHP's internal file pointer back to the beginning of a
compressed file. It returns TRUE on success, FALSE if there is an error.


<?

Free download pdf