How to convert a string to uppercase in PHP?

by wilmer.lemke , in category: PHP General , a year ago

How to convert a string to uppercase in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , a year ago

@wilmer.lemke 

In PHP, you can convert a string to uppercase using the strtoupper() function. This function takes a string as its argument and returns a new string with all the characters in uppercase.


Here's an example:

1
2
3
$string = "Hello World!";
$uppercase_string = strtoupper($string);
echo $uppercase_string; // outputs "HELLO WORLD!"


In the example above, the strtoupper() function is used to convert the string "Hello World!" to "HELLO WORLD!". The resulting uppercase string is then printed using the echo statement.