PHP strtoupper() Function (original) (raw)

Last Updated : 11 Sep, 2024

The PHP strtoupper() function converts all alphabetic characters in a given string to uppercase. It takes a string as an argument and returns a new string with all letters capitalized, leaving non-alphabetic characters unchanged.

**Syntax

string strtoupper ( $string )

**Parameter: The only parameter to this function is a string that is to be converted to upper case.

**Return value: This function returns a string in which all the alphabets are uppercase. Examples:

Input : $str = "GeeksForGeeks"
strtoupper($str)
Output: GEEKSFORGEEKS

Input : str="goingBACKheSAWTHIS123str = "going BACK he SAW THIS 123str="goingBACKheSAWTHIS123#%"
strtoupper($str)
Output: GOING BACK HE SAW THIS 123$#%

Below programs illustrate the strtoupper() function in PHP:

**Example: In this example we converts the string “GeeksForGeeks” to uppercase using strtoupper() and prints the result.

PHP `

resStr=strtoupper(resStr = strtoupper(resStr=strtoupper(str); print_r($resStr); ?>

`

**Example : In this example we converts the string “going BACK he SAW THIS 123$#%” to uppercase using strtoupper() and prints the result

PHP `

str="goingBACKheSAWTHIS123str = "going BACK he SAW THIS 123str="goingBACKheSAWTHIS123#%"; // string to upper case resStr=strtoupper(resStr = strtoupper(resStr=strtoupper(str); print_r($resStr); ?>

`

Output

GOING BACK HE SAW THIS 123$#%