Hướng dẫn which function converts a string to all uppercase in php? - chức năng nào chuyển đổi một chuỗi thành tất cả chữ hoa trong php?

(Php 4, Php 5, Php 7, Php 8)

strtouper - tạo một chuỗi chữ hoaMake a string uppercase

Sự mô tả

Strtouper (Chuỗi $string): Chuỗi(string $string): string

Các byte trong phạm vi "a" (0x61) thành "z" (0x7a) sẽ được chuyển đổi thành chữ cái viết hoa tương ứng bằng cách trừ 32 từ mỗi giá trị byte.

Điều này có thể được sử dụng để chuyển đổi các ký tự ASCII trong các chuỗi được mã hóa bằng UTF-8, vì các ký tự UTF-8 Multibyte sẽ bị bỏ qua. Để chuyển đổi các ký tự không phải là ASCII, hãy sử dụng mb_strtoupper ().mb_strtoupper().

Thông số

string

Chuỗi đầu vào.

Trả về giá trị

Trả về chuỗi bán dẫn.

Thay đổi

Phiên bảnSự mô tả
8.2.0 Strtouper (Chuỗi $string): Chuỗisetlocale(). Only ASCII characters will be converted.

Các byte trong phạm vi "a" (0x61) thành "z" (0x7a) sẽ được chuyển đổi thành chữ cái viết hoa tương ứng bằng cách trừ 32 từ mỗi giá trị byte.

Điều này có thể được sử dụng để chuyển đổi các ký tự ASCII trong các chuỗi được mã hóa bằng UTF-8, vì các ký tự UTF-8 Multibyte sẽ bị bỏ qua. Để chuyển đổi các ký tự không phải là ASCII, hãy sử dụng mb_strtoupper ().strtoupper() example

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>

Thông số

string: This function is binary-safe.

Chuỗi đầu vào.

  • Trả về giá trị
  • Trả về chuỗi bán dẫn.
  • Thay đổi
  • Phiên bản

Chuyển đổi trường hợp không còn phụ thuộc vào tập hợp địa phương với setlocale (). Chỉ các ký tự ASCII sẽ được chuyển đổi.

Ví dụ

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:

setlocale

(LC_CTYPE, 'de_DE.UTF8');

echo

strtoupper('Umlaute äöü in uppercase'); // outputs "UMLAUTE äöü IN UPPERCASE"
echo mb_strtoupper('Umlaute äöü in uppercase', 'UTF-8'); // outputs "UMLAUTE ÄÖÜ IN UPPERCASE"?>

Ví dụ #1 Strtouper () Ví dụ

Ghi chú

Here is how to make the character in upper case, except HTML-entities:

"a"0

"a"1

"a"2

Lưu ý: Hàm này an toàn cho nhị phân.

Xem thêm

"a"3

strtolower () - tạo chữ thường chuỗi

ucfirst () - Tạo nhân vật chữ hoa đầu tiên của chuỗi

"a"4

"a"5

"a"2

ucwords () - chữ hoa, ký tự đầu tiên của mỗi từ trong một chuỗi

mb_strtoupper () - tạo một chuỗi chữ hoa

"a"7

"a"8

Andre tại Koethur Dot de ¶

9 năm trước

uilmind tại fv.com.ua ¶

"z"0

"z"1

"z"2

"z"3

"z"4

"z"6

"z"7

6 năm trước

MEC tại Stadeleck Dot org ¶

"z"8

"z"9

string0

"a"2

ucwords () - chữ hoa, ký tự đầu tiên của mỗi từ trong một chuỗi

mb_strtoupper () - tạo một chuỗi chữ hoa

string2

string3

string4

Andre tại Koethur Dot de ¶

9 năm trước

uilmind tại fv.com.ua ¶

string6

string7

string8

string9

6 năm trước

MEC tại Stadeleck Dot org ¶

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
0

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
1

"a"2

19 năm trước

mb_strtoupper () - tạo một chuỗi chữ hoa

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
3

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
4

"a"2

Andre tại Koethur Dot de ¶

9 năm trước

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
6

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
7

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
8

$str "Mary Had A Little Lamb and She LOVED It So";
$str strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
9

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:0

uilmind tại fv.com.ua ¶

6 năm trước

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:1

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:2

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:3

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:4

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:5

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:6

"a"2

MEC tại Stadeleck Dot org ¶

19 năm trước

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:8

One might think that setting the correct locale would do the trick with for example german umlauts, but this is not the case. You have to use mb_strtoupper() instead:9

0

1

"a"2

Bart tại Insane Dot tại ¶

16 năm trước

Ẩn danh ¶

18 năm trước

MEC tại Stadeleck Dot org ¶

4

5

6

7

Làm thế nào tôi có thể viết hoa một chuỗi trong PHP?

Hàm strtouper () được sử dụng để chuyển đổi một chuỗi thành chữ hoa.Hàm này lấy một chuỗi làm tham số và chuyển đổi tất cả các bảng chữ cái tiếng Anh thường có trong chuỗi thành chữ hoa.strtoupper() function is used to convert a string into uppercase. This function takes a string as parameter and converts all the lowercase english alphabets present in the string to uppercase.

Chức năng nào chuyển đổi chữ cái đầu tiên của chuỗi trong chữ hoa trong PHP?

Hàm ucfirst () chuyển đổi ký tự đầu tiên của chuỗi thành chữ hoa.Các hàm liên quan: lcfirst () - Chuyển đổi ký tự đầu tiên của chuỗi thành chữ thường.UCWords () - Chuyển đổi ký tự đầu tiên của mỗi từ trong một chuỗi thành chữ hoa.ucfirst() function converts the first character of a string to uppercase. Related functions: lcfirst() - converts the first character of a string to lowercase. ucwords() - converts the first character of each word in a string to uppercase.