mirror of
https://github.com/php/php-src.git
synced 2024-10-19 15:34:25 +00:00
102 lines
1.7 KiB
PHP
102 lines
1.7 KiB
PHP
--TEST--
|
||
Test sprintf() function : usage variations - char formats with boolean values
|
||
--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() : char formats with boolean values ***\n";
|
||
|
||
// array of boolean values
|
||
$boolean_values = array(
|
||
true,
|
||
false,
|
||
TRUE,
|
||
FALSE,
|
||
);
|
||
|
||
// array of char formats
|
||
$char_formats = array(
|
||
"%c", "%hc", "%lc",
|
||
"%Lc", " %c", "%c ",
|
||
"\t%c", "\n%c", "%4c",
|
||
"%30c", "%[a-bA-B@#$&]", "%*c"
|
||
);
|
||
|
||
$count = 1;
|
||
foreach($boolean_values as $boolean_value) {
|
||
echo "\n-- Iteration $count --\n";
|
||
|
||
foreach($char_formats as $format) {
|
||
var_dump( sprintf($format, $boolean_value) );
|
||
}
|
||
$count++;
|
||
};
|
||
|
||
echo "Done";
|
||
?>
|
||
--EXPECTF--
|
||
*** Testing sprintf() : char formats with boolean values ***
|
||
|
||
-- Iteration 1 --
|
||
string(1) ""
|
||
string(1) "c"
|
||
string(1) ""
|
||
string(1) "c"
|
||
string(2) " "
|
||
string(2) " "
|
||
string(2) " "
|
||
string(2) "
|
||
"
|
||
string(1) ""
|
||
string(1) ""
|
||
string(11) "a-bA-B@#$&]"
|
||
string(1) "c"
|
||
|
||
-- Iteration 2 --
|
||
string(1) " |