1--TEST-- 2Test ctype_xdigit() function : usage variations - heaxadecimal and octal values 3--SKIPIF-- 4<?php require_once('skipif.inc'); ?> 5--FILE-- 6<?php 7/* 8 * Pass different hexadecimal and octal values that: 9 * 1. contain hexadecimal digits 10 * 2. correspond to character codes recognised as hexadecimal digits (see variation2) 11 * referred to as 'correct' integers below 12 */ 13 14echo "*** Testing ctype_xdigit() : usage variations ***\n"; 15 16$orig = setlocale(LC_CTYPE, "C"); 17 18// contain hexadecimal digits but do not correspond to 'correct' ints 19$octal_values1 = array(012, 013, 014, 015); 20 21// correspond to 'correct' integers 22$octal_values2 = array(061, 062, 063, 064); 23 24// contain hexadecimal digits but do not correspond to 'correct' ints 25$hex_values1 = array(0x1A, 0x1B, 0x1C, 0x1D); 26 27//correspond to 'correct' integers 28$hex_values2 = array(0x61, 0x62, 0x63, 0x64); 29 30echo "\n-- Octal values --\n"; 31echo "'Incorrect' Integers: \n"; 32foreach($octal_values1 as $c) { 33 var_dump(ctype_xdigit($c)); 34} 35echo "'Correct' Integers: \n"; 36foreach($octal_values2 as $c) { 37 var_dump(ctype_xdigit($c)); 38} 39 40echo "\n-- Hexadecimal values --\n"; 41echo "'Incorrect' Integers: \n"; 42foreach($hex_values1 as $c) { 43 var_dump(ctype_xdigit($c)); 44} 45echo "'Correct' Integers: \n"; 46foreach($hex_values2 as $c) { 47 var_dump(ctype_xdigit($c)); 48} 49setlocale(LC_CTYPE, $orig); 50?> 51--EXPECT-- 52*** Testing ctype_xdigit() : usage variations *** 53 54-- Octal values -- 55'Incorrect' Integers: 56bool(false) 57bool(false) 58bool(false) 59bool(false) 60'Correct' Integers: 61bool(true) 62bool(true) 63bool(true) 64bool(true) 65 66-- Hexadecimal values -- 67'Incorrect' Integers: 68bool(false) 69bool(false) 70bool(false) 71bool(false) 72'Correct' Integers: 73bool(true) 74bool(true) 75bool(true) 76bool(true) 77