If you know the string is small use
$stream = fopen(sprintf('data://text/plain,%s', $string), 'r');
$result = stream_get_contents($stream);
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).
If data is large - better use