PHP ctype_upper() 函数用法及示例 - PHP教程

由网友 大卫 发布 阅读 2

PHP ctype_upper() 函数用法及示例 - PHP教程

PHP Ctype 函数手册

ctype_upper()函数检查字符串里面的字符是不是都是大写字母。

语法

ctype_upper ( $text );

定义和用法

此函数检查所提供的字符串(文本)中的所有字符是否均为大写字母。

参数

序号参数及说明
1

text(必需)

被测试的字符串。

返回值

如果文本中的每个字符在当前语言环境中均为大写字母,则返回TRUE。

在线示例

检测字符串中,是否所有字母均为大写,注意看以下示例

<?php
   $strings = array('test12345', 'ABCEFG','222ADFDS','testText');
   
   foreach ($strings as $test) {
      if (ctype_upper($test)) {
         echo "$test 全部为大写字母 \n";
      }else {
         echo "$test 不全为大写字母 \n";
      }
   }
?>
测试看看‹/›

输出结果

test12345 不全为大写字母 
ABCEFG 全部为大写字母 
222ADFDS 不全为大写字母 
testText 不全为大写字母

  PHP Ctype 函数手册

PHP scandir() PHP ctype_space()