1--TEST-- 2Test sprintf() function : basic functionality - float format 3--FILE-- 4<?php 5/* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]]) 6 * Description: Return a formatted string 7 * Source code: ext/standard/formatted_print.c 8*/ 9 10echo "*** Testing sprintf() : basic functionality - using float format ***\n"; 11 12 13// Initialise all required variables 14 15$format = "format"; 16$format1 = "%f"; 17$format2 = "%f %f"; 18$format3 = "%f %f %f"; 19 20$format11 = "%F"; 21$format22 = "%F %F"; 22$format33 = "%F %F %F"; 23$arg1 = 11.11; 24$arg2 = 22.22; 25$arg3 = 33.33; 26 27// Calling sprintf() with default arguments 28var_dump( sprintf($format) ); 29 30// Calling sprintf() with two arguments 31var_dump( sprintf($format1, $arg1) ); 32var_dump( sprintf($format11, $arg1) ); 33 34// Calling sprintf() with three arguments 35var_dump( sprintf($format2, $arg1, $arg2) ); 36var_dump( sprintf($format22, $arg1, $arg2) ); 37 38// Calling sprintf() with four arguments 39var_dump( sprintf($format3, $arg1, $arg2, $arg3) ); 40var_dump( sprintf($format33, $arg1, $arg2, $arg3) ); 41 42echo "Done"; 43?> 44--EXPECTF-- 45*** Testing sprintf() : basic functionality - using float format *** 46string(6) "format" 47string(9) "11.110000" 48string(9) "11.110000" 49string(19) "11.110000 22.220000" 50string(19) "11.110000 22.220000" 51string(29) "11.110000 22.220000 33.330000" 52string(29) "11.110000 22.220000 33.330000" 53Done 54