Example 1 — Convert Text to Uppercase
Pass a string and get an uppercase copy back.
<?php
$text = "Hello world";
$upper = strtoupper($text);
echo $upper, PHP_EOL;
echo $text, PHP_EOL; How It Works
- Create a string. It contains lowercase letters.
- Call strtoupper(). It returns an uppercase copy.
- Print the copy. You see
HELLO WORLD. - Original is unchanged.
$textkeeps its case.

