Below you will find pages that utilize the taxonomy term “Stream Wrapper”
PHP: A Custom Stream Wrapper Part 2: Reading and Seeking
In my previous post about the experimental DOM stream wrapper, I discussed the issues that came forth when opening the stream. Now, let’s take a look at another very important thing you want to do with a stream: read from and to it, and maybe move the pointer back and forth.
Reading from the stream
The DOM stream wrapper is already able to open an XML file and look for a specified node in the DOM:
PHP: Setting up a Stream Wrapper for Manipulating the DOM
I recently felt a strong urge to write something about implementing a stream wrapper for PHP. A stream wrapper is a way to handle file interaction of any kind. PHP has built-in stream wrappers for HTTP, FTP, the filesystem, etc. But you are also allowed to implement custom protocols using your own stream wrapper. Stream wrappers are used by all file functions, like fopen()
and fgets()
. Creating a custom stream wrapper begins with creating a class (it does not have to extend anything) and then making a call to stream_wrapper_register
. In this post (and future posts on the same subject) I will develop a stream wrapper for manipulating a DOMNode
’s value using traditional file manipulation functions. The stream wrapper class is called “DOMStreamWrapper” and we register it for the protocol “dom”: