So this is something that I have not been able to find any documentation on. I have a plain text string that I am trying to turn into a stream in php.
$myStr = "A bit of text +test +test2";
$stream = fopen('data://text/plain,' . $myStr, 'r');
var_dump(stream_get_contents($stream);
The output of this code is
A bit of text test test2
I tried using preg_replace to add an escape to the plus signs however this did not seem to have any effect. Any other ideas? Thanks
You could use base64_encode:
Here’s an example.
The reason for the issue is that it’s a URI, and in HTTP URIs a
+is an encoded space. Your other choice is to use urlencode (example).