1--TEST-- 2Test vsprintf() function : usage variations - with whitespaces in format strings 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); 6?> 7--FILE-- 8<?php 9/* Prototype : string vsprintf(string $format , array $args) 10 * Description: Return a formatted string 11 * Source code: ext/standard/formatted_print.c 12*/ 13 14echo "*** Testing vsprintf() : with white spaces in format strings ***\n"; 15 16// initializing the format array 17$formats = array( 18 "% d % d % d", 19 "% f % f % f", 20 "% F % F % F", 21 "% b % b % b", 22 "% c % c % c", 23 "% e % e % e", 24 "% u % u % u", 25 "% o % o % o", 26 "% x % x % x", 27 "% X % X % X", 28 "% E % E % E" 29); 30 31// initializing the args array 32 33$args_array = array( 34 array(111, 222, 333), 35 array(1.1, .2, -0.6), 36 array(1.12, -1.13, +0.23), 37 array(1, 2, 3), 38 array(65, 66, 67), 39 array(2e1, 2e-1, -2e1), 40 array(-11, +22, 33), 41 array(012, -02394, +02389), 42 array(0x11, -0x22, +0x33), 43 array(0x11, -0x22, +0x33), 44 array(2e1, 2e-1, -2e1) 45); 46 47$counter = 1; 48foreach($formats as $format) { 49 echo"\n-- Iteration $counter --\n"; 50 var_dump( vsprintf($format, $args_array[$counter-1]) ); 51 $counter++; 52} 53 54echo "Done"; 55?> 56--EXPECTF-- 57*** Testing vsprintf() : with white spaces in format strings *** 58 59-- Iteration 1 -- 60string(13) "111 222 333" 61 62-- Iteration 2 -- 63string(29) "1.100000 0.200000 -0.600000" 64 65-- Iteration 3 -- 66string(29) "1.120000 -1.130000 0.230000" 67 68-- Iteration 4 -- 69string(9) "1 10 11" 70 71-- Iteration 5 -- 72string(7) "A B C" 73 74-- Iteration 6 -- 75string(38) "2.000000e+1 2.000000e-1 -2.000000e+1" 76 77-- Iteration 7 -- 78string(28) "18446744073709551605 22 33" 79 80-- Iteration 8 -- 81string(30) "12 1777777777777777777755 23" 82 83-- Iteration 9 -- 84string(24) "11 ffffffffffffffde 33" 85 86-- Iteration 10 -- 87string(24) "11 FFFFFFFFFFFFFFDE 33" 88 89-- Iteration 11 -- 90string(38) "2.000000E+1 2.000000E-1 -2.000000E+1" 91Done 92