English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ctype_punct() function checks if printable characters do not include whitespace, numbers, and letters.
ctype_punct($text);
This function checks if all characters in the provided string are punctuation symbols.
Serial number | Parameters and descriptions |
---|---|
1 | text (required) The string being tested |
If each character in the text is printable but not a letter, number, or whitespace, it returns TRUE; otherwise, it returns FALSE.
An instance of ctype_punct() to check if characters are all punctuation symbols.
<?php $strings = array('k211!@!$#, 'foo!#$bar', ''*$()); foreach ($strings as $test) { if (ctype_punct($test)) { echo "$test Punctuation marks \n"; }else { echo "$test Non-punctuation characters \n"; } } ?>Test and see‹/›
Output result:
k211!@!$# Non-punctuation characters foo!#$bar Non-punctuation characters *Punctuation marks