strtoupper
Converts ASCII letters to uppercase.
Syntax
strtoupper(string $string): stringParameters
| Parameter | Type | Description |
|---|---|---|
| $string | string | The source string. |
Return value
stringThe string in uppercase.
Examples
Uppercase:
<?php
echo strtoupper('hello world');Output:
HELLO WORLDCyrillic stays unchanged — it needs mb_strtoupper():
<?php
echo strtoupper('php и питон'), "\n";
echo mb_strtoupper('php и питон');Output:
PHP и питон
PHP И ПИТОНNotes
For user-entered text choose mb_strtoupper(): it works with any alphabet.
See also
- strtolower — Converts ASCII letters to lowercase.
- mb_strtoupper — Converts a string to uppercase.
- ucwords — Uppercases the first letter of every word.
Related recipes
In the tutorial
- Strings — Working with strings in PHP — quotes, concatenation, length, searching, replacing and multibyte functions.