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