Using the PHP Function Stream_Context_Get_Default
If you’ve ever tried to move files around your computer, you have probably used a stream. Streams are a generalized way of handling file, network, data compression and other operations that share common behavior.
There are many wrappers built in to PHP for a variety of protocols/encodings (see List of Supported Protocols/Wrappers). Custom wrappers may be added within a script using stream_wrapper_register(), or directly from an extension (see API Reference in Working with streams).
A context is a set of parameters and wrapper specific options that enhance and modify the behavior of a stream. Contexts are created using the stream_context_create() function and can be passed to most filesystem related stream creation functions (i.e fopen(), file(), and file_get_contents()).
In the example above the default error context is errcontext, which contains all errors that occur while reading or writing to the stream. It is important that you do not modify errcontext or the variables in it, but instead use an array of error objects, like the one above, to get the information that you need.
errcontext also contains the timeout parameter, which is the maximum amount of time, in seconds and microseconds, that a stream should elapse before it times out. If you pass a 0 timeout value to stream_select(), the result will be TRUE, although it is not recommended for use in loops as this could cause excessive CPU usage. Generally, it is better to poll the status of streams more frequently but with a shorter timeout.