1--TEST-- 2Test vprintf() function : usage variations - float formats with non-float values 3--FILE-- 4<?php 5/* 6 * Test vprintf() when different float formats and non-float values are passed to 7 * the '$format' and '$args' arguments of the function 8*/ 9 10echo "*** Testing vprintf() : float formats and non-float values ***\n"; 11 12// defining array of float formats 13$formats = 14 '%f %+f %-f 15 %lf %4f %-4f 16 %10.4f %-10.4f %04f %04.4f 17 %\'#2f %\'2f %\'$2f %\'_2f 18 %3$f %4$f %1$f %2$f'; 19 20// Arrays of non float values for the format defined in $format. 21// Each sub array contains non float values which correspond to each format in $format 22$args_array = array( 23 24 // array of int values 25 array(2, -2, +2, 26 123456, -12346789, +12346789, 27 123200, +20000, -40000, 22212, 28 12345780, 1211111, -12111111, -12345634, 29 3, +4, 1,-2 ), 30 31 // array of strings 32 array(" ", ' ', 'hello', 33 '123hello', '-123hello', '+123hello', 34 "\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello', 35 "1234hello", "hello\0world", "NULL", "true", 36 "3", "4", '1', '2'), 37 38 // different arrays 39 array( array(0), array(1, 2), array(-1, -1), 40 array("123"), array('-123'), array("-123"), 41 array(true), array(false), array(TRUE), array(FALSE), 42 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"), 43 array("3"), array("4"), array("1"), array("2") ), 44 45 // array of boolean data 46 array( true, TRUE, false, 47 TRUE, FALSE, 1, 48 true, false, TRUE, FALSE, 49 0, 1, 1, 0, 50 1, TRUE, 0, FALSE), 51 52); 53 54// looping to test vprintf() with different float formats from the above $format array 55// and with non-float values from the above $args_array array 56$counter = 1; 57foreach($args_array as $args) { 58 echo "\n-- Iteration $counter --\n"; 59 $result = vprintf($formats, $args); 60 echo "\n"; 61 var_dump($result); 62 $counter++; 63} 64 65?> 66--EXPECT-- 67*** Testing vprintf() : float formats and non-float values *** 68 69-- Iteration 1 -- 702.000000 -2.000000 2.000000 71 123456.000000 -12346789.000000 12346789.000000 72 123200.0000 20000.0000 -40000.000000 22212.0000 73 12345780.000000 1211111.000000 -12111111.000000 -12345634.000000 74 2.000000 123456.000000 2.000000 -2.000000 75int(245) 76 77-- Iteration 2 -- 780.000000 +0.000000 0.000000 79 123.000000 -123.000000 123.000000 80 0.0000 0.0000 123456.000000 0.0000 81 1234.000000 0.000000 0.000000 0.000000 82 0.000000 123.000000 0.000000 0.000000 83int(197) 84 85-- Iteration 3 -- 861.000000 +1.000000 1.000000 87 1.000000 1.000000 1.000000 88 1.0000 1.0000 1.000000 1.0000 89 1.000000 1.000000 1.000000 1.000000 90 1.000000 1.000000 1.000000 1.000000 91int(180) 92 93-- Iteration 4 -- 941.000000 +1.000000 0.000000 95 1.000000 0.000000 1.000000 96 1.0000 0.0000 1.000000 0.0000 97 0.000000 1.000000 1.000000 0.000000 98 0.000000 1.000000 1.000000 1.000000 99int(180) 100