
ctype_alpha() 函数检测字符串中所有字符是否都为字母
语法
ctype_alpha ( $text );
定义和用法
它检查提供的字符串,文本中的所有字符是否都是字母。
参数
| 序号 | 参数及说明 | 
|---|---|
| 1 | text(必需) 要测试的字符串。 | 
返回值
 如果在当前语言环境中 text 里的每个字符都是一个字母,那么就返回TRUE,反之则返回FALSE。 
在线示例
检测数组元素是否全是由字母组成。
<?php
   $strings = array('example', 'example1234');
   
   foreach ($strings as $test) {
      if (ctype_alpha($test)) {
         echo "$test 全部是字母。\n";
      }else {
         echo "$test 不全是字母。 \n";
      }
   }
?>测试看看‹/›输出结果:
example 全部是字母。 example1234 不全是字母。
