1--TEST-- 2Test ctype_cntrl() function : usage variations - Different strings 3--EXTENSIONS-- 4ctype 5--FILE-- 6<?php 7/* 8 * Pass strings containing different character types to ctype_cntrl() to test 9 * which are considered valid control character only strings 10 */ 11 12echo "*** Testing ctype_cntrl() : 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 base64_decode("w4DDoMOHw6fDiMOo"), // non-ascii characters 40 "\n", 41/*25*/ "\r", 42 "\t", 43 "0xD", 44 "0xA", 45 "0xE", 46/*30*/ "\t\r\n", 47); 48 49 50// loop through each element of $values to test behaviour of ctype_cntrl() 51$iterator = 1; 52foreach($values as $value) { 53 echo "\n-- Iteration $iterator --\n"; 54 var_dump( ctype_cntrl($value) ); 55 $iterator++; 56}; 57 58setlocale(LC_CTYPE, $orig); 59?> 60--EXPECT-- 61*** Testing ctype_cntrl() : usage variations *** 62 63-- Iteration 1 -- 64bool(false) 65 66-- Iteration 2 -- 67bool(false) 68 69-- Iteration 3 -- 70bool(false) 71 72-- Iteration 4 -- 73bool(false) 74 75-- Iteration 5 -- 76bool(false) 77 78-- Iteration 6 -- 79bool(false) 80 81-- Iteration 7 -- 82bool(false) 83 84-- Iteration 8 -- 85bool(false) 86 87-- Iteration 9 -- 88bool(false) 89 90-- Iteration 10 -- 91bool(true) 92 93-- Iteration 11 -- 94bool(false) 95 96-- Iteration 12 -- 97bool(false) 98 99-- Iteration 13 -- 100bool(false) 101 102-- Iteration 14 -- 103bool(false) 104 105-- Iteration 15 -- 106bool(false) 107 108-- Iteration 16 -- 109bool(false) 110 111-- Iteration 17 -- 112bool(false) 113 114-- Iteration 18 -- 115bool(false) 116 117-- Iteration 19 -- 118bool(false) 119 120-- Iteration 20 -- 121bool(false) 122 123-- Iteration 21 -- 124bool(false) 125 126-- Iteration 22 -- 127bool(false) 128 129-- Iteration 23 -- 130bool(false) 131 132-- Iteration 24 -- 133bool(true) 134 135-- Iteration 25 -- 136bool(true) 137 138-- Iteration 26 -- 139bool(true) 140 141-- Iteration 27 -- 142bool(false) 143 144-- Iteration 28 -- 145bool(false) 146 147-- Iteration 29 -- 148bool(false) 149 150-- Iteration 30 -- 151bool(true) 152