import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / vprintf_variation10.php
blobc1417b4f249161155bb38b8febc23a829cb5b9b7
1 <?php
2 /* Prototype : string vprintf(string format, array args)
3 * Description: Output a formatted string
4 * Source code: ext/standard/formatted_print.c
5 */
7 /*
8 * Test vprintf() when different char formats and non-char values are passed to
9 * the '$format' and '$args' arguments of the function
12 echo "*** Testing vprintf() : char formats and non-char values ***\n";
14 // defining an array of various char formats
15 $formats =
16 '%c %+c %-c
17 %lc %Lc %4c %-4c
18 %10.4c %-10.4c %04c %04.4c
19 %\'10c %\'10c %\'$10c %\'_10c
20 %3$c %4$c %1$c %2$c';
22 // Arrays of non char values for the format defined in $format.
23 // Each sub array contains non char values which correspond to each format in $format
24 $args_array = array(
26 // array of float values
27 array(65.8, -65.8, +66.8,
28 93.2, -93.2, 126.8, -126.49,
29 35.44, -35.68, 32.99, -32.00,
30 -61.51, 61.51, 50.49, -54.50,
31 83.33, +84.44, 81.11, 82.22),
33 // array of int values
34 array(65, -65, +66,
35 169, -169, 126, -126,
36 35, -35, 32, -32,
37 -61, 61, 50, -54,
38 83, +84, 81, 82),
40 // array of strings
41 array(" ", ' ', 'hello',
42 '123hello', "123hello", '-123hello', '+123hello',
43 "\12345678hello", "-\12345678hello", '0123456hello', 'h123456ello',
44 "1234hello", "hello\0world", "NULL", "true",
45 "3", "4", '1', '2'),
47 // different arrays
48 array( array(0), array(1, 2), array(-1, -1),
49 array("123"), array('123'), array('-123'), array("-123"),
50 array(true), array(false), array(TRUE), array(FALSE),
51 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
52 array("3"), array("4"), array("1"), array("2") ),
54 // array of boolean data
55 array( true, TRUE, false,
56 TRUE, 0, FALSE, 1,
57 true, false, TRUE, FALSE,
58 0, 1, 1, 0,
59 1, TRUE, 0, FALSE),
63 // looping to test vprintf() with different char formats from the above $format array
64 // and with non-char values from the above $args_array array
65 $counter = 1;
66 foreach($args_array as $args) {
67 echo "\n-- Iteration $counter --\n";
68 $result = vprintf($formats, $args);
69 echo "\n";
70 var_dump($result);
71 $counter++;
75 ===DONE===