Open In App

PHP strtoupper() Function

Last Updated : 11 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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 = "going BACK he SAW THIS 123$#%"
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
<?php
// original string
$str = "GeeksForGeeks";

// string converted to upper case
$resStr = strtoupper($str);

print_r($resStr);


?>

Output
GEEKSFORGEEKS

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

PHP
<?php

// original string
$str = "going BACK he SAW THIS 123$#%";

// string to upper case
$resStr = strtoupper($str);

print_r($resStr);

?>

Output
GOING BACK HE SAW THIS 123$#%

Next Article

Similar Reads