Write a PHP program to convert a string into uppercase
Description: Write a PHP program to convert all the characters of a string into uppercase.
Rules and hints:
- Use only one variable.
- Use a PHP built-in string function.
PHP program to convert a string into uppercase
<?php
$str = "Tutorials Class";
echo strtoupper($str);
?>
Output:
Tutorials Class - Output Window
TUTORIALS CLASS
How it works
strtoupper()returns the string with all letters in capital.- For text in other languages (like accents) use
mb_strtoupper().
Related: PHP String Handling and ucwords().
Learn more about the similar topics:
| Tutorials |
|---|
| PHP String Handling |
| PHP explode() Function |
| PHP strpos() Function |
| PHP implode() Function |