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