25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

i<br />

Chapter 11<br />

Streams and Network<br />

Programming<br />

An often-forgotten feature of <strong>PHP</strong> is the streams layer. First introduced in <strong>PHP</strong> 4.3 by<br />

Wez Furlong, the streams layer is most often used without even knowing that it exists:<br />

whenever you access a file using fopen(), file(), readfile(), include, require and a<br />

multitude of other functions, <strong>PHP</strong> uses the functionality provided by the streams<br />

layer to do the actual “dirty work.”<br />

The streams layer is an abstraction layer for file access. The term “stream” refers to<br />

the fact that a number of different resource—like files, but also network connections,<br />

compression protocols, and so on—can be considered “streams” of data to be read<br />

and/or written either in sequence or at random.<br />

There are some security considerations connected with the use of file-access operations<br />

and the streams layer. They are discussed in the Security chapter.<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

There are two types of streams. One group provides access to a certain type of<br />

stream resource; the standard <strong>PHP</strong> distribution includes several built in examples of<br />

these:<br />

• php.*—standard <strong>PHP</strong> input/output

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!