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