ctype_punct
Description
The ctype_punct of Ctype for PHP checks 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.
When called with an empty string the result will always be false.
Examples
1 · text
<? $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: ~