1--TEST--
2Test posix_strerror() function : usage variations
3--SKIPIF--
4<?php
5	if(!extension_loaded("posix")) print "skip - POSIX extension not loaded";
6?>
7--FILE--
8<?php
9/* Prototype  : proto string posix_strerror(int errno)
10 * Description: Retrieve the system error message associated with the given errno.
11 * Source code: ext/posix/posix.c
12 * Alias to functions:
13 */
14
15echo "*** Testing posix_strerror() : usage variations ***\n";
16
17// Initialise function arguments not being substituted (if any)
18
19//get an unset variable
20$unset_var = 10;
21unset ($unset_var);
22
23//array of values to iterate over
24$values = array(
25
26      // float data
27      10.5,
28      -10.5,
29      10.1234567e10,
30      10.7654321E-10,
31      .5,
32
33      // array data
34      array(),
35      array(0),
36      array(1),
37      array(1, 2),
38      array('color' => 'red', 'item' => 'pen'),
39
40      // null data
41      NULL,
42      null,
43
44      // boolean data
45      true,
46      false,
47      TRUE,
48      FALSE,
49
50      // empty data
51      "",
52      '',
53
54      // string data
55      "string",
56      'string',
57
58      // undefined data
59      $undefined_var,
60
61      // unset data
62      $unset_var,
63
64      // object data
65      new stdclass(),
66);
67
68// loop through each element of the array for errno
69
70foreach($values as $value) {
71      echo "\nArg value $value \n";
72      echo gettype( posix_strerror($value) )."\n";
73};
74
75echo "Done";
76?>
77--EXPECTF--
78*** Testing posix_strerror() : usage variations ***
79
80Notice: Undefined variable: undefined_var in %s on line %d
81
82Notice: Undefined variable: unset_var in %s on line %d
83
84Arg value 10.5
85string
86
87Arg value -10.5
88string
89
90Arg value 101234567000
91string
92
93Arg value 1.07654321E-9
94string
95
96Arg value 0.5
97string
98
99Arg value Array
100
101Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d
102boolean
103
104Arg value Array
105
106Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d
107boolean
108
109Arg value Array
110
111Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d
112boolean
113
114Arg value Array
115
116Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d
117boolean
118
119Arg value Array
120
121Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d
122boolean
123
124Arg value
125string
126
127Arg value
128string
129
130Arg value 1
131string
132
133Arg value
134string
135
136Arg value 1
137string
138
139Arg value
140string
141
142Arg value
143
144Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d
145boolean
146
147Arg value
148
149Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d
150boolean
151
152Arg value string
153
154Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d
155boolean
156
157Arg value string
158
159Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d
160boolean
161
162Arg value
163string
164
165Arg value
166string
167
168Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d
169