php-src/ext/standard/tests/strings/sprintf_basic3.phpt
Steph Fox 87fac43ac0 - killed off UEXPECT
- html_translation_table and setlocale tests are no longer relevant
- there are a number of ANSI-encoded files. Is this deliberate?
2008-05-27 10:50:48 +00:00

54 lines
1.3 KiB
PHP

--TEST--
Test sprintf() function : basic functionality - float format
--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() : basic functionality - using float format ***\n";
// Initialise all required variables
$format = "format";
$format1 = "%f";
$format2 = "%f %f";
$format3 = "%f %f %f";
$format11 = "%F";
$format22 = "%F %F";
$format33 = "%F %F %F";
$arg1 = 11.11;
$arg2 = 22.22;
$arg3 = 33.33;
// Calling sprintf() with default arguments
var_dump( sprintf($format) );
// Calling sprintf() with two arguments
var_dump( sprintf($format1, $arg1) );
var_dump( sprintf($format11, $arg1) );
// Calling sprintf() with three arguments
var_dump( sprintf($format2, $arg1, $arg2) );
var_dump( sprintf($format22, $arg1, $arg2) );
// Calling sprintf() with four arguments
var_dump( sprintf($format3, $arg1, $arg2, $arg3) );
var_dump( sprintf($format33, $arg1, $arg2, $arg3) );
echo "Done";
?>
--EXPECT--
*** Testing sprintf() : basic functionality - using float format ***
unicode(6) "format"
unicode(9) "11.110000"
unicode(9) "11.110000"
unicode(19) "11.110000 22.220000"
unicode(19) "11.110000 22.220000"
unicode(29) "11.110000 22.220000 33.330000"
unicode(29) "11.110000 22.220000 33.330000"
Done