The ucfirst()
function in PHP converts the first character of a string to uppercase.
The figure below shows a visual representation of the ucfirst()
function.
ucfirst(string $string): string
The ucfirst()
function requires a string whose first character is to be converted to uppercase.
The ucfirst()
function returns the input string, with the first character changed to uppercase and the rest of the string unchanged.
The code below shows how the ucfirst()
function works.
<?php#stringecho("ucfirst('educative'): ");echo (ucfirst('educative'));echo("\n");#string with numberecho("ucfirst('educaTive09'): ");echo (ucfirst('educaTive09'));?>