简体   繁体   English

PHP如何建立修复Stream Wrapper

[英]PHP How to build repairing Stream Wrapper

我需要修复即时从互联网上传入的XML文档的一部分,这意味着我正在使用流,迫不及待要加载整个文档,因为文件太大了,我没有有这么多时间:)所以我考虑使用流包装器,但是我有点卡住了如何实现它,实际上我没有找到实现stream_read()的线索-Methods ....可以你帮我吗?

As far as you're looking for some example code for a Stream-Wrapper class, see Example class registered as stream wrapper . 至于您正在寻找Stream-Wrapper类的示例代码,请参阅示例类注册为stream wrapper

As you have not shared much about the nature of the fixes you want to apply on the streamed data, it's hard to provide more information. 由于您尚未就要应用于流式数据的修补程序的性质分享太多信息,因此很难提供更多信息。

Maybe a stream filter is something less complex which does the job as well for you. 也许流过滤器不太复杂,它也可以为您完成这项工作。 And based on your comments this looks more appropriate as you do not want to care about providing the stream but working with it. 根据您的评论,这看起来更合适,因为您不想关心提供流而是使用它。 See the manual page for stream_filter_register() which has an example on how to filter the stream on the fly. 请参见手册手册中的stream_filter_register() ,其中包含有关如何动态过滤流的示例。

As you have not shared what actually is broken and as XML is a file-format that needs to be fully loaded into memory to deal with it correctly (strictly spoken), I can not say if a stream filter really is appropriate or not. 由于您尚未共享实际上已损坏的内容,并且XML是一种文件格式,需要将其完全加载到内存中才能正确处理它(严格地说),所以我不能说流过滤器是否确实合适。

Strictly spoken: It might not be technically possible what you try to achieve because of the nature of XML. 严格地说:由于XML的性质,您尝试实现的技术上可能不可行。

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

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