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

(singke) #1

/*
* print a file, then print the first line again
/


// open a local file
if(!($myFile = gzopen("data.gz", "r")))
{
print("file could not be opened");
exit;
}


while(!gzeof($myFile))
{
// read a line from the file
$myLine = gzgetss($myFile, 255);
print("$myLine
\n");
}


gzrewind($myFile);
$myLine = gzgetss($myFile, 255);
print("$myLine
\n");


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


integer gzseek(integer file_handle, integer offset)


This function works exactly like fseek, except that it operates on compressed files.


<?
// open a file
if(!($myFile = gzopen("data.gz", "r")))
{
print("file could not be opened");
exit;
}


// jump 32 bytes into the file
gzseek($myFile, 32);


$myLine = gzgets($myFile, 255);
print($myLine);


// dump the rest of the file
gzpassthru($myFile);
?>


integer gztell(integer file_handle)

Free download pdf