For my understanding of streams in PHP, a stream is an interface that provides methods for
reading from and writing to a resource and this interface is implemented by different
types of stream wrappers (http,ftp,file etc) for providing specific functionality.
So when we say fopen() opens up stream, does it mean instantiation of a specific stream
wrapper object?
Please clarify me if i am wrong
Thanks
Introduction ¶ A wrapper is additional code which tells the stream how to handle specific protocols/encodings. For example, the http wrapper knows how to translate a URL into an HTTP/1.0 request for a file on a remote server.
PHP Stream Introduction Streams are the way of generalizing file, network, data compression, and other operations which share a common set of functions and uses. In its simplest definition, a stream is a resource object which exhibits streamable behavior.
The PHP HTTP(Hyper Text Transfer Protocol) functions allow us to handle the information which is sent to the browser by the web server. The purpose of the HTTP extension is to provide comfort and robust set of functionality for major applications.
Not all streams are implemented at that level, most built-ins are at C level, so no, as far as PHP is concerned not a streamwrapper
object. That interface makes sure it works like a stream, not the other way around. (In essence: all streamwrappers can be accessed like a stream resource, but not all stream resources are provided by streamwrapper classes). You can however override for instance the file:///
wrapper and other built-ins, great fun.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With