Return to sprintf_basic3.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test 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: 10: echo "*** 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 28: var_dump( sprintf($format) ); 29: 30: // Calling sprintf() with two arguments 31: var_dump( sprintf($format1, $arg1) ); 32: var_dump( sprintf($format11, $arg1) ); 33: 34: // Calling sprintf() with three arguments 35: var_dump( sprintf($format2, $arg1, $arg2) ); 36: var_dump( sprintf($format22, $arg1, $arg2) ); 37: 38: // Calling sprintf() with four arguments 39: var_dump( sprintf($format3, $arg1, $arg2, $arg3) ); 40: var_dump( sprintf($format33, $arg1, $arg2, $arg3) ); 41: 42: echo "Done"; 43: ?> 44: --EXPECTF-- 45: *** Testing sprintf() : basic functionality - using float format *** 46: string(6) "format" 47: string(9) "11.110000" 48: string(9) "11.110000" 49: string(19) "11.110000 22.220000" 50: string(19) "11.110000 22.220000" 51: string(29) "11.110000 22.220000 33.330000" 52: string(29) "11.110000 22.220000 33.330000" 53: Done