简体   繁体   中英

what is stream and stream wrapper in php

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM