When passing plain string without base64 encoding, do not forget to pass the string through URLENCODE(), because PHP automatically urldecodes all entities inside passed string (and therefore all + get lost, all % entities will be converted to the corresponding characters).
In this case, PHP is strictly compilant with the RFC 2397. Section 3 states that passes data should be either in base64 encoding or urlencoded.
VALID USAGE:
<?php
$fp = fopen('data:text/plain,'.urlencode($data), 'rb'); $fp = fopen('data:text/plain;base64,'.base64_encode($data), 'rb'); ?>
Demonstration of invalid usage:
<?php
$data = 'Günther says: 1+1 is 2, 10%40 is 20.';
$fp = fopen('data:text/plain,'.$data, 'rb'); echo stream_get_contents($fp);
$fp = fopen('data:text/plain,'.urlencode($data), 'rb'); echo stream_get_contents($fp);
$fp = fopen('data:text/plain;base64,'.base64_encode($data), 'rb'); echo stream_get_contents($fp);
?>