简体   繁体   English

什么是PHP中的流和流包装器

[英]what is stream and stream wrapper in php

For my understanding of streams in PHP, a stream is an interface that provides methods for 为了理解PHP中的流,流是一个提供方法的接口
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. 用于提供特定功能的流包装器类型(http,ftp,file等)。 So when we say fopen() opens up stream, does it mean instantiation of a specific stream 因此,当我们说fopen()打开流时,它是否意味着特定流的实例化
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. 并非所有流都是在该级别实现的,大多数内置函数都是C级别,所以不是,因为PHP不是一个streamwrapper对象。 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). (实质上:所有streamwrappers都可以像流资源一样访问,但并非所有流资源都由streamwrapper类提供)。 You can however override for instance the file:/// wrapper and other built-ins, great fun. 但是你可以覆盖例如file:///包装器和其他内置插件,非常有趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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