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/* Prototype  : bool ctype_xdigit(mixed $c)
8 * Description: Checks for character(s) representing a hexadecimal digit
9 * Source code: ext/ctype/ctype.c
10 */
11
12/*
13 * Pass different hexadecimal and octal values that:
14 * 1. contain hexadecimal digits
15 * 2. correspond to character codes recognised as hexadecimal digits (see variation2)
16 *    referred to as 'correct' integers below
17 */
18
19echo "*** Testing ctype_xdigit() : usage variations ***\n";
20
21$orig = setlocale(LC_CTYPE, "C");
22
23// contain hexadecimal digits but do not correspond to 'correct' ints
24$octal_values1 = array(012, 013, 014, 015);
25
26// correspond to 'correct' integers
27$octal_values2 = array(061, 062, 063, 064);
28
29// contain hexadecimal digits but do not correspond to 'correct' ints
30$hex_values1 = array(0x1A, 0x1B, 0x1C, 0x1D);
31
32//correspond to 'correct' integers
33$hex_values2 = array(0x61, 0x62, 0x63, 0x64);
34
35echo "\n-- Octal values --\n";
36echo "'Incorrect' Integers: \n";
37foreach($octal_values1 as $c) {
38	var_dump(ctype_xdigit($c));
39}
40echo "'Correct' Integers: \n";
41foreach($octal_values2 as $c) {
42	var_dump(ctype_xdigit($c));
43}
44
45echo "\n-- Hexadecimal values --\n";
46echo "'Incorrect' Integers: \n";
47foreach($hex_values1 as $c) {
48	var_dump(ctype_xdigit($c));
49}
50echo "'Correct' Integers: \n";
51foreach($hex_values2 as $c) {
52	var_dump(ctype_xdigit($c));
53}
54setlocale(LC_CTYPE, $orig);
55?>
56===DONE===
57--EXPECTF--
58*** Testing ctype_xdigit() : usage variations ***
59
60-- Octal values --
61'Incorrect' Integers:
62bool(false)
63bool(false)
64bool(false)
65bool(false)
66'Correct' Integers:
67bool(true)
68bool(true)
69bool(true)
70bool(true)
71
72-- Hexadecimal values --
73'Incorrect' Integers:
74bool(false)
75bool(false)
76bool(false)
77bool(false)
78'Correct' Integers:
79bool(true)
80bool(true)
81bool(true)
82bool(true)
83===DONE===
84