Streams are resources provided by PHP that we often use transparently, but which can also be very powerful tools. By learning how to harness their power, we can take our applications to a higher level.
Every stream has a implementation wrapper which has the additional code necessary to handle the specific protocol or encoding. PHP provides some built-in wrappers and we can easily create and register custom ones. We can even modify or enhance the behavior of wrappers using contexts and filters.
A context can modify or enhance the behavior of a stream
A context is a set of parameters and stream wrapper specific options
The following functions accepts a stream $context parameter.
- fopen
- file_get_contents
- file