English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP ctype_upper() Function Usage and Example

PHP Ctype Function Manual

The ctype_upper() function checks if all characters in the string are uppercase letters.

Syntax

ctype_upper(\$text);

Definition and Usage

This function checks if all characters in the provided string (text) are uppercase letters.

Parameter

Serial NumberParameters and Description
1

text (required)

The string to be tested.

Return Value

If each character in the text is an uppercase letter in the current locale, it returns TRUE.

Online Example

Check if all letters in the string are uppercase, see the following examples

<?php
   \$strings = array('test12345', 'ABCEFG','222ADFDS','testText');
   
   foreach (\$strings as \$test) {
      if (ctype_upper(\$test)) {
         echo "\$test are all in uppercase letters\n";
      }else {
         echo "\$test is not entirely in uppercase letters\n";
      }
   }
?>
Test and see‹/›

Output Result

test12345 is not entirely in uppercase letters 
ABCEFG are all in uppercase letters 
222ADFDS is not entirely in uppercase letters 
testText is not entirely in uppercase letters

  PHP Ctype Function Manual