Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test script for php bug reporting related to stream and filter convert.base64-encode #75910
<?php
$testString = 'test';
$stream = fopen('php://memory', 'r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-encode');
echo "encode - low-level - memory = " . stream_get_contents($stream) . PHP_EOL;
$testString = 'dGVzdA==';
$stream = fopen('php://memory', 'r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-decode');
echo "decode - low-level - memory = " . stream_get_contents($stream) . PHP_EOL;
$testString = 'test';
$stream = fopen('php://temp', 'r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-encode');
echo "encode - low-level - temp = " . stream_get_contents($stream) . PHP_EOL;
$testString = 'dGVzdA==';
$stream = fopen('php://temp', 'r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-decode');
echo "decode - low-level - temp = " . stream_get_contents($stream) . PHP_EOL;
macOS 10.13.3 (17D47) - brew.sh 7.1.13_24
PHP 7.1.13 (cli) (built: Jan 5 2018 15:31:15) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
encode - low-level - memory = dGVzdA==
decode - low-level - memory = test
encode - low-level - temp = dGVzdA==
decode - low-level - temp = test
macOS 10.13.3 (17D47) - brew.sh (7.2.1_12)
PHP 7.2.1 (cli) (built: Jan 5 2018 17:34:14) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
encode - low-level - memory = dGVzdA==
decode - low-level - memory = test
encode - low-level - temp = dGVz
decode - low-level - temp = test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.