File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
strings /
sprintf_variation6.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 sprintf() function : usage variations - int formats with arrays
--FILE--
<?php
/* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
* Description: Return a formatted string
* Source code: ext/standard/formatted_print.c
*/
echo "*** Testing sprintf() : integer formats with arrays ***\n";
// different arrays used to test the function
$array_types = array (
array(),
array(0),
array(1),
array(-123),
array("123"),
array("-123"),
array(NULL),
array(null),
array("string"),
array(true),
array(TRUE),
array(false),
array(FALSE),
array(1,2,3,4),
array(1 => "One", "two" => 2)
);
// various integer formats
$int_formats = array(
"%d", "%hd", "%ld",
"%Ld", " %d", "%d ",
"\t%d", "\n%d", "%4d",
"%30d", "%[0-9]", "%*d"
);
$count = 1;
foreach($array_types as $arr) {
echo "\n-- Iteration $count --\n";
foreach($int_formats as $format) {
var_dump( sprintf($format, $arr) );
}
$count++;
};
echo "Done";
?>
--EXPECTF--
*** Testing sprintf() : integer formats with arrays ***
-- Iteration 1 --
string(1) "0"
string(1) "d"
string(1) "0"
string(1) "d"
string(2) " 0"
string(2) "0 "
string(2) " 0"
string(2) "
0"
string(4) " 0"
string(30) " 0"
string(4) "0-9]"
string(1) "d"
-- Iteration 2 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 3 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 4 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 5 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 6 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 7 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 8 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 9 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 10 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 11 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 12 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 13 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 14 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
-- Iteration 15 --
string(1) "1"
string(1) "d"
string(1) "1"
string(1) "d"
string(2) " 1"
string(2) "1 "
string(2) " 1"
string(2) "
1"
string(4) " 1"
string(30) " 1"
string(4) "0-9]"
string(1) "d"
Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>