Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

strtoupper

Converts ASCII letters to uppercase.

Syntax

strtoupper(string $string): string

Parameters

ParameterTypeDescription
$stringstringThe source string.

Return value

stringThe string in uppercase.

Examples

Uppercase:

<?php
 
echo strtoupper('hello world');

Output:

HELLO WORLD

Cyrillic 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.

Thanks for reading!

Donate to the site — we work hard for you.