1--TEST-- 2Test ctype_xdigit() function : usage variations - Different strings 3--EXTENSIONS-- 4ctype 5--FILE-- 6<?php 7/* 8 * Pass strings containing different character types to ctype_xdigit() to test 9 * which are considered valid hexadecimal 'digit' only strings 10 */ 11 12echo "*** Testing ctype_xdigit() : 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 'ABCdef07', 41 "56ea\tFB", 42 "0x2A" 43 ); 44 45$iterator = 1; 46foreach($values as $value) { 47 echo "\n-- Iteration $iterator --\n"; 48 var_dump( ctype_xdigit($value) ); 49 $iterator++; 50}; 51 52setlocale(LC_CTYPE, $orig); 53?> 54--EXPECT-- 55*** Testing ctype_xdigit() : usage variations *** 56 57-- Iteration 1 -- 58bool(false) 59 60-- Iteration 2 -- 61bool(false) 62 63-- Iteration 3 -- 64bool(false) 65 66-- Iteration 4 -- 67bool(false) 68 69-- Iteration 5 -- 70bool(true) 71 72-- Iteration 6 -- 73bool(false) 74 75-- Iteration 7 -- 76bool(false) 77 78-- Iteration 8 -- 79bool(false) 80 81-- Iteration 9 -- 82bool(false) 83 84-- Iteration 10 -- 85bool(false) 86 87-- Iteration 11 -- 88bool(true) 89 90-- Iteration 12 -- 91bool(true) 92 93-- Iteration 13 -- 94bool(false) 95 96-- Iteration 14 -- 97bool(false) 98 99-- Iteration 15 -- 100bool(true) 101 102-- Iteration 16 -- 103bool(true) 104 105-- Iteration 17 -- 106bool(true) 107 108-- Iteration 18 -- 109bool(true) 110 111-- Iteration 19 -- 112bool(false) 113 114-- Iteration 20 -- 115bool(false) 116 117-- Iteration 21 -- 118bool(false) 119 120-- Iteration 22 -- 121bool(false) 122 123-- Iteration 23 -- 124bool(false) 125 126-- Iteration 24 -- 127bool(true) 128 129-- Iteration 25 -- 130bool(false) 131 132-- Iteration 26 -- 133bool(false) 134