How to convert lowercase to uppercase in php string
How to convert php string from lowercase to uppercase: 1. Use strtoupper() function, syntax "strtoupper($string)"; 2. Use mb_strtoupper() function, syntax "mb_strtoupper($string,$encoding) )".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php string will Convert lowercase to uppercase
Method 1: Use strtoupper() function
strtoupper() function can convert letters in a string to uppercase , the syntax format is as follows:
strtoupper($string)
Among them, $string is a parameter of string type. This function can convert the letters in the parameter $string to uppercase and return the converted string.
The sample code is as follows:
<?php $str = "https://www.php.cn/"; $str = strtoupper($str); echo $str; ?>
The running results are as follows:
HTTPS://WWW.PHP.CN/
Method 2: Use the mb_strtoupper() function
mb_strtoupper( ) The function of the function is similar to the strtoupper() function. It can also convert letters in the string to uppercase, and the mb_strtoupper() function can also set the character encoding of the parameter. Its syntax is as follows:
mb_strtoupper($string [, $encoding = mb_internal_encoding()])
Among them, $string is the string that needs to be converted, and $encoding is an optional parameter used to set the character encoding of the parameter.
The difference from the strtoupper() function is that the letters in $string are determined through the Unicode character attribute. Therefore, the mb_strtoupper() function is not affected by the locale setting and can convert any character with a "letter" attribute, such as a umlaut (ä).
The sample code is as follows:
<?php header("Content-type:text/html;charset=utf-8"); $str = "https://www.php.cn/"; $str = mb_strtoupper($str); echo $str . '<br>'; $str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός"; $str = mb_strtoupper($str, 'UTF-8'); echo $str; ?>
The running results are as follows:
The above is the detailed content of How to convert lowercase to uppercase in php string. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
