1--TEST--
2Test ctype_alnum() function : usage variations - Different data types as $c arg
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7/*
8 * Pass different data types as $c argument to ctype_alnum() to test behaviour
9 */
10
11echo "*** Testing ctype_alnum() : usage variations ***\n";
12
13$orig = setlocale(LC_CTYPE, "C");
14
15//get an unset variable
16$unset_var = 10;
17unset ($unset_var);
18
19// get a class
20class classA
21{
22  public function __toString() {
23    return "xyz";
24  }
25}
26
27// heredoc string
28$heredoc = <<<EOT
29123
30EOT;
31
32// get a resource variable
33$fp = fopen(__FILE__, "r");
34
35// unexpected values to be passed to $c argument
36$inputs = array(
37
38       // int data
39/*1*/  0,
40       1,
41       12345,
42       -2345,
43
44       // float data
45/*5*/  10.5,
46       -10.5,
47       12.3456789000e10,
48       12.3456789000E-10,
49       .5,
50
51       // null data
52/*10*/ NULL,
53       null,
54
55       // boolean data
56/*12*/ true,
57       false,
58       TRUE,
59       FALSE,
60
61       // empty data
62/*16*/ "",
63       '',
64       array(),
65
66       // string data
67/*19*/ "pqr",
68       'LMN',
69       $heredoc,
70
71       // object data
72/*22*/ new classA(),
73
74       // undefined data
75/*23*/ @$undefined_var,
76
77       // unset data
78/*24*/ @$unset_var,
79
80       // resource variable
81/*25*/ $fp
82);
83
84// loop through each element of $inputs to check the behavior of ctype_alnum()
85$iterator = 1;
86foreach($inputs as $input) {
87  echo "\n-- Iteration $iterator --\n";
88  var_dump( ctype_alnum($input) );
89  $iterator++;
90};
91
92fclose($fp);
93
94setlocale(LC_CTYPE, $orig);
95?>
96--EXPECT--
97*** Testing ctype_alnum() : usage variations ***
98
99-- Iteration 1 --
100bool(false)
101
102-- Iteration 2 --
103bool(false)
104
105-- Iteration 3 --
106bool(true)
107
108-- Iteration 4 --
109bool(false)
110
111-- Iteration 5 --
112bool(false)
113
114-- Iteration 6 --
115bool(false)
116
117-- Iteration 7 --
118bool(false)
119
120-- Iteration 8 --
121bool(false)
122
123-- Iteration 9 --
124bool(false)
125
126-- Iteration 10 --
127bool(false)
128
129-- Iteration 11 --
130bool(false)
131
132-- Iteration 12 --
133bool(false)
134
135-- Iteration 13 --
136bool(false)
137
138-- Iteration 14 --
139bool(false)
140
141-- Iteration 15 --
142bool(false)
143
144-- Iteration 16 --
145bool(false)
146
147-- Iteration 17 --
148bool(false)
149
150-- Iteration 18 --
151bool(false)
152
153-- Iteration 19 --
154bool(true)
155
156-- Iteration 20 --
157bool(true)
158
159-- Iteration 21 --
160bool(true)
161
162-- Iteration 22 --
163bool(false)
164
165-- Iteration 23 --
166bool(false)
167
168-- Iteration 24 --
169bool(false)
170
171-- Iteration 25 --
172bool(false)
173