PHP - Function ctype_upper()


Advertisements


Syntax

ctype_upper ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, are uppercase characters.

Parameters

Parameter Description
1

text

Required. The tested string.

Return Value

Returns TRUE if every character in text is an uppercase letter in the current locale.

Example

Try out following example −

<?php
   $strings = array('AbCd1zyZ9', 'FOOBAR');
   
   foreach ($strings as $testcase) {
      if (ctype_upper($testcase)) {
         echo "$testcase consists of all uppercase letters. \n";
      }else {
         echo "$testcase does not have all uppercase letters. \n";
      }
   }
?> 

This will produce following result −

AbCd1zyZ9 does not have all uppercase letters.
FOOBAR consists of all uppercase letters.

php_function_reference.htm