I am looking for a way to implement a read-only stream with predefined content inside.
There is an internal thread in PHP php://memory. It can be opened in various modes with fopen, one of which ris a read-only stream.
The problem is that there seems to be no way to initiate it with some content. Obviously, writing to a read-only stream is not supported (I exclude it hhvmhere, which apparently supports it - by creating ).
I know the wrapper data://. Using it, you really can initialize a read-only stream with data inside, although the data must be base64 / urlencoded, which implies some restriction on the possible encoding. Also, I could not find documentation about where the data stream is actually stored (in memory or in a temporary file?).
source
share