
ctype_punct() 函数检测可打印的字符是不是不包含空白、数字和字母 。
语法
ctype_punct ( $text );
定义和用法
此函数检查所提供的字符串,文本中的所有字符是否均为标点符号。
参数
| 序号 | 参数及说明 | 
|---|---|
| 1 | text(必需) 被测试的字符串。 | 
返回值
 如果在 text 里面的每个字符都是能打印的,但不是字母、数字,也不是空白,那么就返回 TRUE ;反之则返回 FALSE 。 
在线示例
一个 ctype_punct() 的实例检测字符是否全为标点符号。
<?php
   $strings = array('k211!@!$#', 'foo!#$bar', '*$()');
   
   foreach ($strings as $test) {
      if (ctype_punct($test)) {
         echo "$test 由标点符号组成 \n";
      }else {
         echo "$test 含非标点符号字符 \n";
      }
   }
?>测试看看‹/›输出结果:
k211!@!$# 含非标点符号字符 foo!#$bar 含非标点符号字符 *$() 由标点符号组成
