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

(singke) #1

Given a valid file handle, gztell returns the offset of PHP's internal file pointer.


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


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


print("


\n");
print("File pointer at ". gztell($myFile). " bytes");


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


gzwrite


The gzwrite function is an alias to gzputs.


integer readgzfile(string filename, boolean use_include_path)


The readgzfile function operates identically to the readfile function, except that it
expects the file to be compressed. The file is uncompressed on the fly and sent directly to
the browser.


<?
//dump uncompressed contents of
//data.gz to browser
readgzfile("data.gz");
?>


POSIX


Kristian Koehntopp added a module to PHP to support the POSIX.1 standard, also known
as IEEE 1003.1. This standard describes functionality provided to user processes by an
operating system. A few functions in this section are not part of the standard, but are
commonly available in System V or BSD UNIX systems.


Many of these functions are available only to the root user. PHP scripts are executed by
the owner of the Web server process, which is usually a special user for just this purpose.
Running the Web server as root is unusual and dangerous. Anyone able to view a PHP

Free download pdf