Friday, September 5, 2025
HomeLanguagesPHP strtoupper() Function

PHP strtoupper() Function

The strtoupper() function is used to convert a string into uppercase. This function takes a string as parameter and converts all the lowercase english alphabets present in the string to uppercase. All other numeric characters or special characters in the string remains 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:

Program 1




<?php
  
// original string
$str = "GeeksForGeeks";
  
// string converted to upper case
$resStr = strtoupper($str);
  
print_r($resStr);
  
?>


Output:

GEEKSFORGEEKS

Program 2




<?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$#%

Reference:
http://php.net/manual/en/function.strtoupper.php

RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS