PHP String ucfirst() Function17 Mar 2025 | 2 min read The ucfirst() function is used to convert the first character of the string into the uppercase. It is an in-built function of PHP, which takes a string as input and converts only the first letter of that string to uppercase. This function converts only the first character of the string to uppercase and others remains unchanged. Note: PHP 4+ versions support this function.There are some related functions in PHP which are similar to the strtolower() function: Related functions
SyntaxThe syntax of the ucfirst() function is given below that contains only one string parameter. The ucfirst() returns the converted string. Parameter$string (required) - It is a mandatory parameter of this function, which specifies the input string. It is the only argument, passed in the ucfirst() function. Return ValuesThe ucfirst() function returns the converted string, where the first character of the string is converted to uppercase. ExamplesThere are some examples given, through which we can learn the working of the ucfirst() function. Let's see the below examples- Example 1 Output: As we can see in the below output that the ucfirst() converts only the first character of the string to uppercase. Hey! myself shivani garg Example 2 Output: Hey! are you Aparna Garg? No, I'm Gunjan Garg. Next TopicPHP String Functions |
PHP String Function PHP string is predefine function which is used to insert HTML line break before all newlines in a string. It returns string with <br \> or <br> before all newlines (\r\n, \n\r, \n and \r). Syntax: nl2br(string,xhtml); Parameter Description Required/Optional String Specify input string required xhtml Boolean value, whether to use XHTML...
1 min read
PHP String Function The is a built-in function of PHP, which is used to convert/transform a formatted string to a specific output stream. In , the arguments are placed in an array. The elements of the array will be inserted along with percent (%) signs...
3 min read
PHP String function The is an in-built function of PHP which is used to find the position of the last occurrence of a substring inside another string. It is a case-sensitive function of PHP, which means it treats uppercase and lowercase characters differently. The is...
4 min read
PHP string function PHP string function is predefined function. It is often used to remove whitespace from both sides of a string or other character from the left side of a string. Syntax: ltrim(string,charlist); Parameter Description Required/Optional String Specify the string to check. Required charlist Specify character to remove from the string. "\0" : NULL "\t" :...
1 min read
PHP string Function The string function is in-built PHP function. It is used to calculates the similarity between two strings in percent. Note: The Levenshtein() function is faster than function. It will give us more accurate result. Syntax: similar_text(string1,string2,percent); Parameter Description Required/Optional String 1 Specify the first string to be compared. required String...
1 min read
PHP String Function The function is a built-in function of PHP which is used to convert an 8-bit string to a quoted-printable string. This function is opposite to the quoted_printable_decode(), and similar to the imap_8bit() function. It returns a quoted printable string that is created...
1 min read
PHP string Function The string function is in-built function of PHP. It is used to set local information. It returns the new current locale and False if the locale functionality is not implemented. Note: It returns value depends on the system. Syntax: Setlocale(constant,location); Parameter Description Required/Optional constant Specify the local information to be...
1 min read
PHP String Function The is a built-in function of PHP, which helps to compare the two strings from a specified start position to specified end position. This function is a binary-safe function and optionally case-sensitive. PHP 5 and above versions support this function. Syntax The syntax of...
3 min read
PHP string Function The is predefined function of PHP. It is used to convert a string to an array. If the split length is specified, then array will be broken down into chunks with length. It will return FALSE if the split length is less than...
1 min read
PHP String Function The function converts special characters into HTML entities. It is the in-built function of PHP, which converts all pre-defined characters to the HTML entities. The pre-defined characters are: & (ampersand) converted as &amp; " (double quote) converted as &quot; ' (single quote) converted as...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India