Skip to content Skip to sidebar Skip to footer

Functions of ucfirst () lcfirst () and ucwords () in PHP

PHP logo

There are three components used to easily change the prefix of words to uppercase, lowercase, or automatic naming, and these three components are manual functions created by PHP.

All of these functions can be used to create article titles, nicknames / places, etc. And all three codes relate to word prefixes.

The three functions are ucfirst, lcfirst, and ucwords and in order to know the function of each one, one of the three functions is explained one after the other.

ucfirst () function
UC which does ______________ mean Capital letter or in Indonesian bold face that only sees the beginning of the character of each word entered. For example like this.

Look at each upper or lower case letter of the text you entered, and the result of the code above is: Paijo is reading a book. The difference to writing P. those related to paijo are changed to capital since ucfirst only reads the prefix of the first word and not every word.

lcfirst () function
LC which does ______________ mean lowercase letters or in Indonesian, Small is Text, which just reads large text from the beginning of the word to make it small. For example, look at the following code.

Look at each upper or lower case letter of the text you entered, and the result of the code above is: Paijo is reading a book. The difference to writing P. those that refer to paijo are changed to small because lcfirst only reads the prefix of the first word and not every word.

ucwords () function
UC which does ______________ mean Capital letter or in Indonesian, namely Large Text. Here it differs from ucfirst because this function reads the beginning of each word and makes it large. For example, look at the following code.

Look at each character in the code entered above that uses all lowercase letters, and when called with ucwords the result is: Paijo reads books. The difference is the first character of each word, take a closer look at the code and the results and use this function to know what the difference between ucfirst and lcfirst is.

Perhaps many people are still confused, but if you try out each feature in a practical way, it will definitely be easier to get understandable results. If you have any questions about any of the above, please comment

Hopefully useful and good luck