ctype_punct

Check for any printable character which is not whitespace or an alphanumeric character

Syntax

ctype_punct ( 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 printable, but neither letter, digit or blank, FALSE otherwise.

Examples

1

<?

$text = "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~";

$return = ctype_punct($text);

var_export($return);

?>
true

2

<?

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

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

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

?>
33: !
34: "
35: #
36: $
37: %
38: &
39: '
40: (
41: )
42: *
43: +
44: ,
45: -
46: .
47: /
58: :
59: ;
60: <
61: =
62: >
63: ?
64: @
91: [
92: \
93: ]
94: ^
95: _
96: `
123: {
124: |
125: }
126: ~

PHP

Home Menu