1--TEST-- 2Test sprintf() function : basic functionality - exponential 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 exponential format ***\n"; 11 12// Initialise all required variables 13$format = "format"; 14$format1 = "%e"; 15$format2 = "%E %e"; 16$format3 = "%e %E %e"; 17$arg1 = 1000; 18$arg2 = 2e3; 19$arg3 = +3e3; 20 21// Calling sprintf() with default arguments 22var_dump( sprintf($format) ); 23 24// Calling sprintf() with two arguments 25var_dump( sprintf($format1, $arg1) ); 26 27// Calling sprintf() with three arguments 28var_dump( sprintf($format2, $arg1, $arg2) ); 29 30// Calling sprintf() with four arguments 31var_dump( sprintf($format3, $arg1, $arg2, $arg3) ); 32 33echo "Done"; 34?> 35--EXPECTF-- 36*** Testing sprintf() : basic functionality - using exponential format *** 37string(6) "format" 38string(11) "1.000000e+3" 39string(23) "1.000000E+3 2.000000e+3" 40string(35) "1.000000e+3 2.000000E+3 3.000000e+3" 41Done 42