1--TEST--
2Test base64_encode() function : basic functionality - check algorithm round trips
3--FILE--
4<?php
5/*
6 * Test base64_encode with single byte values.
7 */
8
9echo "*** Testing base64_encode() : basic functionality ***\n";
10
11$values = array(
12    "Hello World",
13    "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]",
14    "\n\t Line with control characters\r\n",
15    "\xC1\xC2\xC3\xC4\xC5\xC6",
16    "\75\76\77\78\79\80"
17);
18
19echo "\n--- Testing base64_encode() with binary string input ---\n";
20
21$counter = 1;
22foreach($values as $str) {
23    echo "-- Iteration $counter --\n";
24
25    $enc = base64_encode($str);
26    $dec = base64_decode($enc);
27
28    if ($dec != $str) {
29        echo "TEST FAILED\n";
30    } else {
31        echo "TEST PASSED\n";
32    }
33
34    $counter ++;
35}
36
37?>
38--EXPECT--
39*** Testing base64_encode() : basic functionality ***
40
41--- Testing base64_encode() with binary string input ---
42-- Iteration 1 --
43TEST PASSED
44-- Iteration 2 --
45TEST PASSED
46-- Iteration 3 --
47TEST PASSED
48-- Iteration 4 --
49TEST PASSED
50-- Iteration 5 --
51TEST PASSED
52