+

PHP Ctype_upper () function

Syntax:
ctype_upper (string text)
Parameter used: -
  • $text:checked string.
Returned value:
The function returns True if each character of the text is uppercase, or False if the text is not uppercase.Examples:
Input: GEEKSFORGEEKS Output: Yes Explanation: All characters of "GEEKSFORGEEKS "in UPPERCASE. Input: GFG2018 Output: No Explanation: In text "GFG2018", `2`,` 0`, `1`,` 8` are not in UPPERCASE. Input: GFG INDIA Output: No Explanation: In String "GFG INDIA" a special character [space]between GFG and INDIA. so answer will be No.
Note:Except string, if we input anything then it will return FALSE.
The following program illustrates the ctype_upper() function in PHP:Program: 1
// PHP program to check the given string
// all characters are capital letters $string1 = ` GEEKSFORGEEKS` ; if (ctype_upper ( $string1 )) { / / if true, then return Yes echo " Yes " ; } else { // if False, then return No echo "No" ; } ?> Exit:
Yes  Program: 2passing an array of strings as text and outputting the result for individual values.       
// PHP program to check the given string
// all characters are capital letters $strings = array ( `GEEKSFORGEEKS` , ` First` , ` PROGRAMAT2018` , `ART ICLE` );  
// Checking the above four lines // using the ctype_upper() function. foreach ( $strings as $test ) { if (ctype_upper ( $test )) { // if true then return Yes echo "Yes" ; } else { // if False, return No echo "No" ; } }  
?>
Exit:
Yes No No Yes
Program: 3Runthe function code ctype_upper(),where there will be a space in the input, a special character, returns False .  

// PHP program to check the given string
// all characters are capital letters $strings = array ( `GEEK @. com` );  
// Check above the given four lines // using the ctype_upper() function. foreach ( $strings as $test ) { if (ctype_upper ( $test )) { // if true then return Yes echo "Yes" ; } else { // if False, return No echo "No" ; } }  
?>
Exit:
No  Links:  http://php.net/manual/en/function.ctype-upper.php                                        
             
                
Get Solution for free from DataCamp guru