Hướng dẫn uppercase first letter php - chữ hoa đầu tiên php

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

UCFIRST - Tạo nhân vật chữ hoa đầu tiên của chuỗiMake a string's first character uppercase

Sự mô tả

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

Lưu ý rằng 'chữ cái' được xác định bởi địa phương hiện tại. Chẳng hạn, trong các ký tự địa phương "C" mặc định như Umlaut-A (ä) sẽ không được chuyển đổi.

Thông số

string

Chuỗi đầu vào.

Trả về giá trị

Trả về chuỗi kết quả.

Ví dụ

Ví dụ #1 ucfirst () ví dụucfirst() example

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>

Xem thêm

  • lcfirst () - Tạo chữ thường ký tự đầu tiên của chuỗi
  • strtolower () - tạo chữ thường chuỗi
  • strtouper () - tạo một chuỗi chữ hoa
  • ucwords () - chữ hoa, ký tự đầu tiên của mỗi từ trong một chuỗi

plemieux ¶

16 năm trước

Simple multi-bytes ucfirst():

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>

Qeremy [atta] gmail [dotta] com ¶

10 năm trước

A proper Turkish solution;

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>

prokur.net - có email của tôi ¶

14 năm trước

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not

mattalexxpub tại gmail dot com ¶

13 năm trước

string0

string1

string2

string3

Mingalevme tại Gmail Dot Com ¶

8 năm trước

string4

string5

Markus Ernst ¶

16 năm trước

string7

string8

Qeremy [atta] gmail [dotta] com ¶

14 năm trước

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
0

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
1

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
2

mattalexxpub tại gmail dot com ¶

8 năm trước

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
4

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
5

Markus Ernst ¶

charliefortune ¶

13 năm trước

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
8

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
9

Simple multi-bytes ucfirst():0

string3

13 năm trước

Simple multi-bytes ucfirst():2

Simple multi-bytes ucfirst():3

string3

Mingalevme tại Gmail Dot Com ¶

Simple multi-bytes ucfirst():5

Simple multi-bytes ucfirst():6

8 năm trước

16 năm trước

Simple multi-bytes ucfirst():8

Simple multi-bytes ucfirst():9

Qeremy [atta] gmail [dotta] com ¶

10 năm trước

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
1

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
2

prokur.net - có email của tôi ¶

10 năm trước

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
4

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
5

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
6

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
7

prokur.net - có email của tôi ¶

14 năm trước

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
8

function my_mb_ucfirst($str) {
   
$fc = mb_strtoupper(mb_substr($str, 0, 1));
    return
$fc.mb_substr($str, 1);
}
?>
9

mattalexxpub tại gmail dot com ¶

13 năm trước

1

2

string3

13 năm trước

4

5

6

7

string3

Mingalevme tại Gmail Dot Com ¶

8

9

A proper Turkish solution;0

A proper Turkish solution;1

A proper Turkish solution;2

A proper Turkish solution;3

A proper Turkish solution;4

8 năm trước

14 năm trước

A proper Turkish solution;6

A proper Turkish solution;7

A proper Turkish solution;8

A proper Turkish solution;9

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
0

mattalexxpub tại gmail dot com ¶

13 năm trước

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
1

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
2

string3

Mingalevme tại Gmail Dot Com ¶

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
4

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
5

8 năm trước

Mingalevme tại Gmail Dot Com ¶

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
7

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
8

8 năm trước

Markus Ernst ¶

0

1

2

3

charliefortune ¶

5

Kiprasbal tại Gmail Dot Com ¶

Markus Ernst ¶

7

8

9

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
0

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
1

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
2

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
3

charliefortune ¶

Kiprasbal tại Gmail Dot Com ¶

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
4

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
5

$foo 'hello world!';
$foo ucfirst($foo);             // Hello world!$bar 'HELLO WORLD!';
$bar ucfirst($bar);             // HELLO WORLD!
$bar ucfirst(strtolower($bar)); // Hello world!
?>
6

14 năm trước

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
7

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) {
    function
mb_ucfirst($string) {
       
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
        return
$string;
    }
}
?>

it also check is mb support enabled or not
8

A proper Turkish solution;9

function ucfirst_turkish($str) {
   
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY);
    return
mb_convert_case(
       
str_replace("i", "İ", $tmp[0]), MB_CASE_TITLE, "UTF-8").
       
$tmp[1];
}
$str = "iyilik güzelLİK";
echo
ucfirst($str) ."\n";   // Iyilik güzelLİK
echo ucfirst_turkish($str); // İyilik güzelLİK
?>
0

mattalexxpub tại gmail dot com ¶

14 năm trước

string01

string02

Markus Ernst ¶

16 năm trước

string04

string05

Qeremy [atta] gmail [dotta] com ¶

14 năm trước

string07

string08

8 năm trước

14 năm trước

string10

string11

8 năm trước

Mingalevme tại Gmail Dot Com ¶

8 năm trước

string14

Markus Ernst ¶

16 năm trước

string16

string17

Qeremy [atta] gmail [dotta] com ¶

13 năm trước

string19

string20

string3

10 năm trước

string22

string23

string24