1--TEST-- 2Test 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 11echo "Decode 'hello world!':\n"; 12$noWhiteSpace = "aGVsbG8gd29ybGQh"; 13var_dump(base64_decode($noWhiteSpace)); 14var_dump(base64_decode($noWhiteSpace, false)); 15var_dump(base64_decode($noWhiteSpace, true)); 16 17echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n"; 18$withWhiteSpace = "a GVs bG8gd2 19 9ybGQh"; 20var_dump(base64_decode($withWhiteSpace)); 21var_dump(base64_decode($withWhiteSpace, false)); 22var_dump(base64_decode($withWhiteSpace, true)); 23 24echo "\nOther chars outside the base64 alphabet are ignored when \$strict===false, but cause failure with \$strict===true:\n"; 25$badChars = $noWhiteSpace . '*'; 26var_dump(base64_decode($badChars)); 27var_dump(base64_decode($badChars, false)); 28var_dump(base64_decode($badChars, true)); 29 30echo "Done"; 31?> 32--EXPECTF-- 33Decode 'hello world!': 34string(12) "hello world!" 35string(12) "hello world!" 36string(12) "hello world!" 37 38Whitespace does not affect base64_decode, even with $strict===true: 39string(12) "hello world!" 40string(12) "hello world!" 41string(12) "hello world!" 42 43Other chars outside the base64 alphabet are ignored when $strict===false, but cause failure with $strict===true: 44string(12) "hello world!" 45string(12) "hello world!" 46bool(false) 47Done 48