A stream is a flow of data that can be read from and written to. Streams were introduced with PHP 4.3. You can work with streams using resource variables and define them using specially structured strings. You might be surprised to discover that we have already done quite a lot of work with streams. Let’s revisit the fopen() function:
$fp = fopen( "/path/to/file.txt", "r" ); $wp = fopen( "http://www.example.com", "r" );
We use fopen() to acquire a resource that can then be used with methods such as fgets(). After we have this resource, we can ignore the fact that the source of the stream we are working with is a Web page or a file. It is just a stream.
In the second call to fopen(), the engine provides an HTTP stream ...