File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
url /
base64_decode_basic_002.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:04 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
Test base64_decode() function : basic functionality - strict vs non-strict with non-base64 chars.
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])
* Description: Decodes string using MIME base64 algorithm
* Source code: ext/standard/base64.c
* Alias to functions:
*/
echo "Decode 'hello world!':\n";
$noWhiteSpace = "aGVsbG8gd29ybGQh";
var_dump(base64_decode($noWhiteSpace));
var_dump(base64_decode($noWhiteSpace, false));
var_dump(base64_decode($noWhiteSpace, true));
echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n";
$withWhiteSpace = "a GVs bG8gd2
9ybGQh";
var_dump(base64_decode($withWhiteSpace));
var_dump(base64_decode($withWhiteSpace, false));
var_dump(base64_decode($withWhiteSpace, true));
echo "\nOther chars outside the base64 alphabet are ignored when \$strict===false, but cause failure with \$strict===true:\n";
$badChars = $noWhiteSpace . '*';
var_dump(base64_decode($badChars));
var_dump(base64_decode($badChars, false));
var_dump(base64_decode($badChars, true));
echo "Done";
?>
--EXPECTF--
Decode 'hello world!':
string(12) "hello world!"
string(12) "hello world!"
string(12) "hello world!"
Whitespace does not affect base64_decode, even with $strict===true:
string(12) "hello world!"
string(12) "hello world!"
string(12) "hello world!"
Other chars outside the base64 alphabet are ignored when $strict===false, but cause failure with $strict===true:
string(12) "hello world!"
string(12) "hello world!"
bool(false)
Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>