Hướng dẫn php uppercase first letter

[PHP 4, PHP 5, PHP 7, PHP 8]

ucfirstMake a string's first character uppercase

Description

ucfirst[string $string]: string

Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a [ä] will not be converted.

Parameters

string

The input string.

Return Values

Returns the resulting string.

Examples

Example #1 ucfirst[] example

See Also

  • lcfirst[] - Make a string's first character lowercase
  • strtolower[] - Make a string lowercase
  • strtoupper[] - Make a string uppercase
  • ucwords[] - Uppercase the first character of each word in a string

plemieux

16 years ago

Simple multi-bytes ucfirst[]:

qeremy [atta] gmail [dotta] com

10 years ago

A proper Turkish solution;

prokur.net - there is my email

14 years ago

I believe that mb_ucfirst will be soon added in PHP, but for now this could be useful


it also check is mb support enabled or not

mattalexxpub at gmail dot com

13 years ago

This is what I use for converting strings to sentence case:

mingalevme at gmail dot com

8 years ago

Implementation of multi-bytes ucfirst for "multiword"-strings [module mbstring is required]:

Markus Ernst

16 years ago

plemieux' function did not work for me without passing the encoding to every single mb function [despite ini_set['default_charset', 'utf-8'] at the top of the script]. This is the example that works in my application [PHP 4.3]:

charliefortune

14 years ago

Here's a function to capitalize segments of a name, and put the rest into lower case. You can pass the characters you want to use as delimiters.

i.e.

Chủ Đề