Home  >  Article  >  Backend Development  >  How to use php ucfirst function

How to use php ucfirst function

藏色散人
藏色散人Original
2019-05-23 15:34:382597browse

php The ucfirst function is used to capitalize the first letter of a string. The ucfirst syntax is ucfirst(string). The parameter string is required and specifies the string to be converted.

How to use php ucfirst function

#php How to use the ucfirst function?

Function: Capitalize the first letter of the string

Syntax:

ucfirst(string)

Parameters:

string Required, specifies the string to be converted.

Description: Convert the first character in the string to uppercase.

php ucfirst() function usage example 1

<?php
$i = "hello world";
$j = ucfirst($i);
echo $j;
?>

Output:

Hello world

php ucfirst() function usage example 2

<?php
echo ucfirst("hi php.cn");
?>

Output:

Hi php.cn

The above is the detailed content of How to use php ucfirst function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn