1--TEST--
2Test ctype_digit() function : usage variations - different strings
3--EXTENSIONS--
4ctype
5--FILE--
6<?php
7/*
8 * Pass strings containing different character types to ctype_digit() to test
9 * which are considered valid decimal digit only strings
10 */
11
12echo "*** Testing ctype_digit() : usage variations ***\n";
13
14$orig = setlocale(LC_CTYPE, "C");
15
16$values = array(
17/*1*/  "This string contains just letters and spaces", // Simple string
18       "but this one contains some numbers too 123+456 = 678", // Mixed string
19       "",
20       " ",
21/*5*/  "a",
22       "ABCXYZ",
23       "abcxyz",
24       "ABCXYZ123DEF456",
25       "abczyz123DEF456",
26/*10*/ "\r\n",
27       "123",
28       ")speci@! ch@r$(",
29       '@!$*',
30       "0",
31/*15*/ "3",
32       "9",
33       "1234",
34       "7890",
35       "0677",
36/*20*/ '0',
37       '3',
38       '9',
39       '1234',
40       '7890',
41/*25*/ "123abc",
42       "abc123",
43       "123\r\t",
44       "123 ",
45       "  123",
46/*30*/ "123E4",
47/*31*/ "0x3F",
48);
49
50$iterator = 1;
51foreach($values as $value) {
52      echo "\n-- Iteration $iterator --\n";
53      var_dump( ctype_digit($value) );
54      $iterator++;
55};
56
57setlocale(LC_CTYPE, $orig);
58?>
59--EXPECT--
60*** Testing ctype_digit() : usage variations ***
61
62-- Iteration 1 --
63bool(false)
64
65-- Iteration 2 --
66bool(false)
67
68-- Iteration 3 --
69bool(false)
70
71-- Iteration 4 --
72bool(false)
73
74-- Iteration 5 --
75bool(false)
76
77-- Iteration 6 --
78bool(false)
79
80-- Iteration 7 --
81bool(false)
82
83-- Iteration 8 --
84bool(false)
85
86-- Iteration 9 --
87bool(false)
88
89-- Iteration 10 --
90bool(false)
91
92-- Iteration 11 --
93bool(true)
94
95-- Iteration 12 --
96bool(false)
97
98-- Iteration 13 --
99bool(false)
100
101-- Iteration 14 --
102bool(true)
103
104-- Iteration 15 --
105bool(true)
106
107-- Iteration 16 --
108bool(true)
109
110-- Iteration 17 --
111bool(true)
112
113-- Iteration 18 --
114bool(true)
115
116-- Iteration 19 --
117bool(true)
118
119-- Iteration 20 --
120bool(true)
121
122-- Iteration 21 --
123bool(true)
124
125-- Iteration 22 --
126bool(true)
127
128-- Iteration 23 --
129bool(true)
130
131-- Iteration 24 --
132bool(true)
133
134-- Iteration 25 --
135bool(false)
136
137-- Iteration 26 --
138bool(false)
139
140-- Iteration 27 --
141bool(false)
142
143-- Iteration 28 --
144bool(false)
145
146-- Iteration 29 --
147bool(false)
148
149-- Iteration 30 --
150bool(false)
151
152-- Iteration 31 --
153bool(false)
154