PHP | IntlChar toupper() Function

The IntlChar::toupper() function is an inbuilt function in PHP which is used to convert the character into Unicode character uppercase. The given character is change with its uppercase equivalent character. If the character has no uppercase equivalent then it returns the same character.

Syntax:

mixed IntlChar::toupper ( $codepoint )

Parameters: This function accepts a single parameter $codepoint which is mandatory. The value of integer $codepoint is (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. “\u{2603}”).



Return Value: This function returns the upper case mapped character of given character. If the given character has no upper case mapped character then it returns the character itself. The return type will be integer unless the code point was passed as a UTF-8 string, in which case a string will be returned.

Below programs illustrate the IntlChar::toupper() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// PHP program to illustrate
// IntlChar::toupper function
  
// Input data is uppercase character symbol
var_dump(IntlChar::toupper("A"));
  
// Input data is lowercase character symbol
var_dump(IntlChar::toupper("a"));
  
// Input data is number symbol
var_dump(IntlChar::toupper("1"));
  
// Input data is string symbol
var_dump(IntlChar::toupper(ord("xyz")));
  
// Input data is uppercase character symbol
var_dump(IntlChar::toupper(ord("I")));
?>

chevron_right


Output:

string(1) "A"
string(1) "A"
string(1) "1"
int(88)
int(73)

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code to illustrate IntlChar::toupper()
       
// Declare an array $arr
$arr = array(ord("A"), "291", "^", "A", "a", "1");
      
// Loop run for every array element
foreach ($arr as $val){
          
    // Check each element as code point data
    var_dump(IntlChar::toupper($val));
}
?>

chevron_right


Output:

int(65)
NULL
string(1) "^"
string(1) "A"
string(1) "A"
string(1) "1"

Related Articles:

Reference: http://php.net/manual/en/intlchar.toupper.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.