1--TEST-- 2Test vsprintf() function : usage variations - scientific formats with scientific values 3--FILE-- 4<?php 5/* Prototype : string vsprintf(string format, array args) 6 * Description: Output a formatted string 7 * Source code: ext/standard/formatted_print.c 8*/ 9 10/* 11 * Test vprintf() when different scientific formats and scientific values 12 * are passed to the '$format' and '$args' arguments of the function 13*/ 14 15echo "*** Testing vprintf() : scientific formats and scientific values ***\n"; 16 17// defining array of scientific formats 18$formats = array( 19 '%e %+e %-e', 20 '%le %Le %4e %-4e', 21 '%10.4e %-10.4e %.4e', 22 '%\'#20e %\'20e %\'$20e %\'_20e', 23 '%3$e %4$e %1$e %2$e' 24); 25 26// Arrays of scientific values for the format defined in $format. 27// Each sub array contains scientific values which correspond to each format string in $format 28$args_array = array( 29 array(0, 1e0, "10e2" ), 30 array(2.2e2, 10e10, 1000e-2, 1000e7), 31 array(-22e12, 10e20, 1.2e2), 32 array(1e1, +1e2, -1e3, "1e2_"), 33 array(3e3, 4e3, 1e3, 2e3) 34); 35 36// looping to test vprintf() with different scientific formats from the above $format array 37// and with signed and other types of values from the above $args_array array 38$counter = 1; 39foreach($formats as $format) { 40 echo "\n-- Iteration $counter --\n"; 41 $result = vprintf($format, $args_array[$counter-1]); 42 echo "\n"; 43 var_dump($result); 44 $counter++; 45} 46 47?> 48===DONE=== 49--EXPECT-- 50*** Testing vprintf() : scientific formats and scientific values *** 51 52-- Iteration 1 -- 530.000000e+0 +1.000000e+0 1.000000e+3 54int(36) 55 56-- Iteration 2 -- 572.200000e+2 e 1.000000e+1 1.000000e+10 58int(38) 59 60-- Iteration 3 -- 61-2.2000e+13 1.0000e+21 1.2000e+2 62int(32) 63 64-- Iteration 4 -- 65#########1.000000e+1 1.000000e+2 $$$$$$$$-1.000000e+3 _________1.000000e+2 66int(74) 67 68-- Iteration 5 -- 691.000000e+3 2.000000e+3 3.000000e+3 4.000000e+3 70int(47) 71===DONE=== 72