ctype_cntrl

Check for control character(s)

Syntax

ctype_cntrl ( mixed $text ) : bool

Parameters

text

The tested string.

Note: If an integer between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer.

Return

Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.

Examples

1

<?

$text = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f\t\n\v\f\r\e";

$return = ctype_cntrl($text);

var_export($return);

?>
true

2

<?

for ($i = 0; $i <= 255; ++$i)
{
    $return = ctype_cntrl($i);

    if ($return)
    {
        $character = chr($i);

        echo "$i: $character\n";
    }
}

?>
0: 
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9:     
10: 

11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
127: 
HomeMenu