Input/output streams
Quite early in development, every programmer stumbles upon the streams term. This seemingly frightening term represents a form of data. Unlike the typical finite type of data, streams represent a potentially unlimited sequence of data. In PHP terms, a stream is a resource object exhibiting streamable behavior. Using various wrappers, the PHP language supports a wide range of streams. The stream_get_wrappers()
function can retrieve a list of all the registered stream wrappers available on the currently running system, such as the following:
php
file
glob
data
http
ftp
zip
compress.zlib
compress.bzip2
https
ftps
phar
The list of wrappers is quite extensive, but not finite. We can also register our own wrappers using the stream_wrapper_register()
function. Each wrapper tells the stream how to handle specific protocols and encodings. Each stream is therefore accessed through the scheme://target
syntax, such as the following:
php://stdin
file:///path/to/file.ext
glob://var/www/html/*.php...