ctype_punct()函数检查不是空格或字母数字字符的任何可打印字符。
ctype_punct(str)
str-测试的字符串
如果文本中的每个字符都是可打印的,则ctype_punct()函数将返回TRUE,但字母,数字或空格均不可打印,否则返回FALSE。
以下是一个例子-
<?php $srr = array('k211!@!$#', 'foo!#$bar', '*$()'); foreach ($srr as $d) { if (ctype_punct($d)) { echo "$d consists of all punctuation. \n"; } else { echo "$d does not have all punctuation. \n"; } } ?>
输出结果
以下是输出-
k211!@!$# does not have all punctuation. foo!#$bar does not have all punctuation. *$() consists of all punctuation.