Annotation of embedaddon/php/ext/standard/tests/url/base64_decode_basic_002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test base64_decode() function : basic functionality - strict vs non-strict with non-base64 chars.
3: --FILE--
4: <?php
5: /* Prototype : proto string base64_decode(string str[, bool strict])
6: * Description: Decodes string using MIME base64 algorithm
7: * Source code: ext/standard/base64.c
8: * Alias to functions:
9: */
10:
11: echo "Decode 'hello world!':\n";
12: $noWhiteSpace = "aGVsbG8gd29ybGQh";
13: var_dump(base64_decode($noWhiteSpace));
14: var_dump(base64_decode($noWhiteSpace, false));
15: var_dump(base64_decode($noWhiteSpace, true));
16:
17: echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n";
18: $withWhiteSpace = "a GVs bG8gd2
19: 9ybGQh";
20: var_dump(base64_decode($withWhiteSpace));
21: var_dump(base64_decode($withWhiteSpace, false));
22: var_dump(base64_decode($withWhiteSpace, true));
23:
24: echo "\nOther chars outside the base64 alphabet are ignored when \$strict===false, but cause failure with \$strict===true:\n";
25: $badChars = $noWhiteSpace . '*';
26: var_dump(base64_decode($badChars));
27: var_dump(base64_decode($badChars, false));
28: var_dump(base64_decode($badChars, true));
29:
30: echo "Done";
31: ?>
32: --EXPECTF--
33: Decode 'hello world!':
34: string(12) "hello world!"
35: string(12) "hello world!"
36: string(12) "hello world!"
37:
38: Whitespace does not affect base64_decode, even with $strict===true:
39: string(12) "hello world!"
40: string(12) "hello world!"
41: string(12) "hello world!"
42:
43: Other chars outside the base64 alphabet are ignored when $strict===false, but cause failure with $strict===true:
44: string(12) "hello world!"
45: string(12) "hello world!"
46: bool(false)
47: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>