Stream functions
Streams
&reftitle.intro;
Streams were introduced with PHP 4.3.0 as
a way of generalizing file, network, data compression, and other
opperations which share a common set of functions and uses. In
its simplest definition, a stream is any I/O conduit for exchanging
information. Some streams work on the local filesystem, some
use network connections (sockets), while others might potentially focus
on communication devices such as printers or modems. Because any variety
of stream may be added to PHP via the
stream_register_wrapper function, there is no
set limit on what can be done with them. See
for a listing of stream wrappers built into PHP.
A stream is referenced as: scheme://target
scheme(string) -
The name of the stream wrapper to be used. Examples include: file,
http, https, ftp, ftps, compress.zlib, compress.bz2, ssl, tls, and php. See
for a list of PHP builtin wrappers.
target -
Depends on the wrapper used. For filesystem related streams this is
typically a path and filename of the desired file. For network related
streams this is typically a hostname often with a path appended. Again, see
for a description of targets for builtin streams.
Filters may also be applied to streams to further process data on its
way into or out of a stream related call. Documentation on this
functionality is comming soon.
&reftitle.required;
&no.requirement;
&reftitle.install;
Streams are an integral part of PHP
as of version 4.3.0. No steps are required to enable them.
&reftitle.runtime;
&no.config;
&reftitle.resources;
&no.resource;
&reftitle.constants;
&no.constants;
Stream Errors
As with any file or socket related function, an opperation on a stream
may fail for a variety of normal reasons (i.e.: Unable to connect to remote
host, file not found, etc...). A stream related call may also fail because
the desired stream is not registered on the running system. See the output of
php_info for a list of streams supported by your
installation of PHP. As with most PHP internal functions
if a failure occours an E_WARNING message will be generated
describing the nature of the error.
&reftitle.examples;
Using file_get_contents() to retrieve data from multiple sources
]]?>
Making a POST request to an https server
]]>
Writting data to a compressed file
]]>
For PHP Streams Development, See Also:
&reference.stream.functions;