Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
IntlChar toupper() function in PHP
The IntlChar::toupper() function converts a character to its Unicode uppercase equivalent. It works with single characters and returns the uppercase version if available.
Syntax
IntlChar::toupper($val)
Parameters
$val − An integer or character encoded as a UTF-8 string. Must be a single character.
Return Value
The function returns the converted uppercase character as a string. If the character is already uppercase or has no uppercase equivalent, the same character is returned. Returns NULL for invalid input.
Example
The following example demonstrates converting characters to uppercase ?
<?php
var_dump(IntlChar::toupper("j"));
echo "<br>";
var_dump(IntlChar::toupper("89"));
echo "<br>";
var_dump(IntlChar::toupper("J"));
echo "<br>";
var_dump(IntlChar::toupper("jkl"));
echo "<br>";
var_dump(IntlChar::toupper("ñ"));
?>
The output of the above code is ?
string(1) "J" NULL string(1) "J" NULL string(2) "Ñ"
Key Points
Only single characters are processed; multi-character strings return
NULLNumbers and symbols return
NULLas they don't have uppercase equivalentsUnicode characters like "ñ" are properly handled
Already uppercase characters remain unchanged
Conclusion
The IntlChar::toupper() function provides Unicode-aware uppercase conversion for single characters. It returns NULL for invalid inputs like numbers or multi-character strings.
