array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.ucfirst.php', 1 => 'ucfirst', ), 'up' => array ( 0 => 'ref.strings.php', 1 => 'Funções de String', ), 'prev' => array ( 0 => 'function.trim.php', 1 => 'trim', ), 'next' => array ( 0 => 'function.ucwords.php', 1 => 'ucwords', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/strings/functions/ucfirst.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
ucfirst — Make a string's first character uppercase
Returns a string with the first character of
string
capitalized, if that character is
an ASCII character in the range from "a"
(0x61) to
"z"
(0x7a).
string
The input string.
Returns the resulting string.
Versão | Descrição |
---|---|
8.2.0 | A conversão de maiúsculas e minúsculas não depende mais da localidade definida com setlocale(). Somente caracteres ASCII serão convertidos. |
Exemplo #1 ucfirst() example
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>