import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / vsprintf_variation4.php
blobe3ecc5daa9e3f0e415d2361c4af5624db0e5ba73
1 <?php
2 /* Prototype : string vsprintf(string format, array args)
3 * Description: Return a formatted string
4 * Source code: ext/standard/formatted_print.c
5 */
7 /*
8 * Test vsprintf() when different int formats and non-int values are passed to
9 * the '$format' and '$args' arguments of the function
12 echo "*** Testing vsprintf() : int formats and non-integer values ***\n";
14 // defining array of int formats
15 $formats =
16 '%d %+d %-d
17 %ld %Ld %4d %-4d
18 %10.4d %-10.4d %.4d %04.4d
19 %\'#2d %\'2d %\'$2d %\'_2d
20 %3$d %4$d %1$d %2$d';
22 // Arrays of non int values for the format defined in $format.
23 // Each sub array contains non int values which correspond to each format in $format
24 $args_array = array(
26 // array of float values
27 array(2.2, .2, 10.2,
28 123456.234, 123456.234, -1234.6789, +1234.6789,
29 2e10, +2e5, 4e3, 22e+6,
30 12345.780, 12.000000011111, -12.00000111111, -123456.234,
31 3.33, +4.44, 1.11,-2.22 ),
33 // array of strings
34 array(" ", ' ', 'hello',
35 '123hello', "123hello", '-123hello', '+123hello',
36 "\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello',
37 "1234hello", "hello\0world", "NULL", "true",
38 "3", "4", '1', '2'),
40 // different arrays
41 array( array(0), array(1, 2), array(-1, -1),
42 array("123"), array('123'), array('-123'), array("-123"),
43 array(true), array(false), array(TRUE), array(FALSE),
44 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
45 array("3"), array("4"), array("1"), array("2") ),
47 // array of boolean data
48 array( true, TRUE, false,
49 TRUE, 0, FALSE, 1,
50 true, false, TRUE, FALSE,
51 0, 1, 1, 0,
52 1, TRUE, 0, FALSE),
56 // looping to test vsprintf() with different int formats from the above $format array
57 // and with non-int values from the above $args_array array
58 $counter = 1;
59 foreach($args_array as $args) {
60 echo "\n-- Iteration $counter --\n";
61 var_dump( vsprintf($formats, $args) );
62 $counter++;
65 echo "Done";