In PHP, it exists two ways to encode content in base64. We can use function base64_encode which takes a string or use the string filter convert.base64-encode to use with a stream. But I can't produce the same result with these two methods.
<?php
$content = "foo";
$encoded1 = base64_encode($content);
$stream = tmpfile();
stream_filter_append($stream, 'convert.base64-encode');
fwrite($stream, $content);
fseek($stream, 0);
$encoded2 = stream_get_contents($stream);
echo sprintf(
"Content encoded with base64_encode(): %s\nContent encoded with convert.base64-encode filter: %s\n",
$encoded1,
$encoded2,
);
Output
Content encoded with base64_encode(): Zm9v
Content encoded with convert.base64-encode filter: Wm05dg==
In the documentation, this citation can be read.
Use of these filters are equivalent to processing all stream data through the base64_encode() and base64_decode() functions respectively.