import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-strings / sprintf_variation8.php
blob944b82f16f8688e5827e83b5a8547917a273ef2c
1 <?php
2 /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
3 * Description: Return a formatted string
4 * Source code: ext/standard/formatted_print.c
5 */
7 echo "*** Testing sprintf() : integer formats with string values ***\n";
9 // array of strings used to test the function
10 $string_values = array (
11 "",
12 '',
13 "0",
14 '0',
15 "1",
16 '1',
17 "-123abc",
18 "123abc",
19 "+123abc",
20 "\x01",
21 '\x01',
22 "\01",
23 '\01',
24 'string',
25 "string",
26 "true",
27 "FALSE",
28 'false',
29 'TRUE',
30 "NULL",
31 'null'
34 // various integer formats
35 $int_formats = array(
36 "%d", "%hd", "%ld",
37 "%Ld", " %d", "%d ",
38 "\t%d", "\n%d", "%4d",
39 "%30d", "%[0-9]", "%*d"
42 $count = 1;
43 foreach($string_values as $string_value) {
44 echo "\n-- Iteration $count --\n";
46 foreach($int_formats as $format) {
47 var_dump( sprintf($format, $string_value) );
49 $count++;
52 echo "Done";