1--TEST--
2Test ctype_alpha() function : usage variations - different strings
3--EXTENSIONS--
4ctype
5--FILE--
6<?php
7/*
8 * Pass strings containing different character types to ctype_alpha() to test
9 * which are considered valid alphabetic character only strings
10 */
11
12echo "*** Testing ctype_alpha() : 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       "03F", // hexadecimal 'digits'
29       ")speci@! ch@r$(",
30       '@!$*',
31/*15*/ 'ABC',
32       'abc',
33       'ABC123',
34       'abc123',
35       'abc123\n',
36/*20*/ 'abc 123',
37       '',
38       ' ',
39/*23*/ base64_decode("w4DDoMOHw6fDiMOo") // non-ascii characters
40);
41
42
43// loop through each element of $values to test behaviour of ctype_alnum()
44$iterator = 1;
45foreach($values as $value) {
46      echo "\n-- Iteration $iterator --\n";
47      var_dump( ctype_alpha($value) );
48      $iterator++;
49};
50
51setlocale(LC_CTYPE, $orig);
52?>
53--EXPECT--
54*** Testing ctype_alpha() : usage variations ***
55
56-- Iteration 1 --
57bool(false)
58
59-- Iteration 2 --
60bool(false)
61
62-- Iteration 3 --
63bool(false)
64
65-- Iteration 4 --
66bool(false)
67
68-- Iteration 5 --
69bool(true)
70
71-- Iteration 6 --
72bool(true)
73
74-- Iteration 7 --
75bool(true)
76
77-- Iteration 8 --
78bool(false)
79
80-- Iteration 9 --
81bool(false)
82
83-- Iteration 10 --
84bool(false)
85
86-- Iteration 11 --
87bool(false)
88
89-- Iteration 12 --
90bool(false)
91
92-- Iteration 13 --
93bool(false)
94
95-- Iteration 14 --
96bool(false)
97
98-- Iteration 15 --
99bool(true)
100
101-- Iteration 16 --
102bool(true)
103
104-- Iteration 17 --
105bool(false)
106
107-- Iteration 18 --
108bool(false)
109
110-- Iteration 19 --
111bool(false)
112
113-- Iteration 20 --
114bool(false)
115
116-- Iteration 21 --
117bool(false)
118
119-- Iteration 22 --
120bool(false)
121
122-- Iteration 23 --
123bool(false)
124