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