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

(singke) #1

The gzgetc function returns a single character from a compressed file. It expects a file
handle as returned by gzopen.


<?
// open compressed file and print each character
if($myFile = gzopen("data.gz", "r"))
{
while(!gzeof($myFile))
{
$myCharacter = gzgetc($myFile);
print($myCharacter);
}


gzclose($myFile);
}
?>


string gzgets(integer file_handle, integer length)


The gzgets function returns a string it reads from a compressed file specified by the file
handle, which must have been created with gzopen. It will attempt to read as many
characters as specified by the length argument less one (presumably this is PHP
showing its C heritage). A linebreak is treated as a stopping point, as is the end of the file.
Linebreaks are included in the return string.


<?
// open file and print each line
if($myFile = gzopen("data.gz", "r"))
{
while(!gzeof($myFile))
{
$myLine = gzgets($myFile, 255);
print($myLine);
}


gzclose($myFile);
}
?>


string gzgetss(integer file_handle, integer length, string
ignore)


The gzgetss function is in all respects identical to gzgets except that it attempts to strip
any HTML or PHP code before returning a string. The optional ignore argument may
contain tags to be ignored.

Free download pdf