1--TEST--
2Test sprintf() function : usage variations - unsigned formats with resource values
3--FILE--
4<?php
5/* Prototype  : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
6 * Description: Return a formatted string
7 * Source code: ext/standard/formatted_print.c
8*/
9
10echo "*** Testing sprintf() : unsigned formats with resource values ***\n";
11
12// resource type variable
13$fp = fopen (__FILE__, "r");
14$dfp = opendir ( dirname(__FILE__) );
15
16// array of resource types
17$resource_values = array (
18  $fp,
19  $dfp
20);
21
22// array of unsigned formats
23$unsigned_formats = array(
24  "%u", "%hu", "%lu",
25  "%Lu", " %u", "%u ",
26  "\t%u", "\n%u", "%4u",
27   "%30u", "%[0-9]", "%*u"
28);
29
30
31$count = 1;
32foreach($resource_values as $resource_value) {
33  echo "\n-- Iteration $count --\n";
34
35  foreach($unsigned_formats as $format) {
36    var_dump( sprintf($format, $resource_value) );
37  }
38  $count++;
39};
40
41// closing the resources
42fclose($fp);
43closedir($dfp);
44
45echo "Done";
46?>
47--EXPECTF--
48*** Testing sprintf() : unsigned formats with resource values ***
49
50-- Iteration 1 --
51string(%d) "%d"
52string(1) "u"
53string(%d) "%d"
54string(1) "u"
55string(%d) " %d"
56string(%d) "%d "
57string(%d) "	%d"
58string(%d) "
59%d"
60string(4) "%s%d"
61string(30) "%s%d"
62string(4) "0-9]"
63string(1) "u"
64
65-- Iteration 2 --
66string(%d) "%d"
67string(1) "u"
68string(%d) "%d"
69string(1) "u"
70string(%d) " %d"
71string(%d) "%d "
72string(%d) "	%d"
73string(%d) "
74%d"
75string(4) "%s%d"
76string(30) "%s%d"
77string(4) "0-9]"
78string(1) "u"
79Done
80