1--TEST--
2Test sprintf() function : usage variations - float 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() : float 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// various float formats
23$float_formats = array(
24  "%f", "%hf", "%lf",
25  "%Lf", " %f", "%f ",
26  "\t%f", "\n%f", "%4f",
27  "%30f", "%[0-9]", "%*f"
28);
29
30$count = 1;
31foreach($resource_values as $resource_value) {
32  echo "\n-- Iteration $count --\n";
33
34  foreach($float_formats as $format) {
35    // with two arguments
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() : float formats with resource values ***
49
50-- Iteration 1 --
51string(%d) "%d.000000"
52string(1) "f"
53string(%d) "%d.000000"
54string(1) "f"
55string(%d) " %d.000000"
56string(%d) "%d.000000 "
57string(%d) "	%d.000000"
58string(%d) "
59%d.000000"
60string(%d) "%d.000000"
61string(30) "%s%d.000000"
62string(4) "0-9]"
63string(1) "f"
64
65-- Iteration 2 --
66string(%d) "%d.000000"
67string(1) "f"
68string(%d) "%d.000000"
69string(1) "f"
70string(%d) " %d.000000"
71string(%d) "%d.000000 "
72string(%d) "	%d.000000"
73string(%d) "
74%d.000000"
75string(%d) "%d.000000"
76string(30) "%s%d.000000"
77string(4) "0-9]"
78string(1) "f"
79Done
80