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