Streams and Network Programming in PHP

Aug 25, 2009 Author: Developer

There are two types of streams. One group provides access to a certain type of
stream resource; the standard PHP distribution includes several built in examples of

• php.*—standard PHP input/output
• file—standard file access
• http—access to remote resources via HTTP
• ftp—access to remote resources via FTP
• compress.zlib—access to compressed data stream using the zlib compression
In addition to these, there are several stream extensions that can be “installed” on
top of the existing one to formchains of filters that act cumulatively on a data stream:
• string.rot13—encodes the data stream using the ROT-13 algorithm
• string.toupper—converts strings to uppercase
• string.tolower—converts strings to lowercase
• string.strip_tags—removes XML tags from a stream
• convert.*—a family of filters that converts to and from the base64 encoding.
• mcrypt.*—a family of filters that encrypts and decrypts data according to multiple
• zlib.*—a family of filters that compressed and decompresses data using the
zlib compression library

While this functionality in itself is very powerful, the real killer feature of streams lies
in the ability to implement streams wrappers and filters in your PHP scripts
is, create your own URI scheme that can access data by any means you desire, or a
filter than can be applied to any existing stream access.

views 6182
  1. Add New Comment