Reputation: 95
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
Upvotes: 9
Views: 3415
Reputation: 70540
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.
Upvotes: 9