Ever since the release of PHP 4, we have been graced with the UCWords function. This function allows us to capitalize specific letters in a string, which has proved especially useful for titles and database input. Even using the function couldn't be easier, as PHP developers will no doubt agree.
PHP's UCWords function is rather simple because we only have to supply the function with the string we want to be converted into uppercase. While it sounds like a fool-proof plan, don't get too hasty because there are similar-looking functions that perform similar tasks. As such, the proper PHP programmer will memorize such functions to increase their work efficiency.
UCWords is used quite a bit in sanitizing database input for first and last names. Since not every registrant on a website is going to take the time to properly capitalize their name, we use the UCWords function to ensure a sense of conformity. This is especially useful in email marketing, where addressing a registrant by their lowercased name is going to come off as unprofessional.
When webmasters want to reach a broad audience for their content, they will alter Meta tags to tell search engines how and to who they should display the webmaster's resource. When webmasters format the "Title" tag for the Meta data, they should capitalize it to show a sense of professionalism. Using UCWords for this task is quite common, since it can dynamically do so.
By applying the UCWords function to a custom-made function, we can also alter strings to keep certain words lowercased. This is especially important for proper news resources, who know that proper title case is going to mean that some prepositions or words need to remain in lower case. By initializing an array of prepositions and selectively making them lowercased, web developers can ensure that there are no mistakes in how a title should appear.
It's important to note that the UCWords function isn't always going to render foreign characters correctly. While this should be fixed in the next version of PHP version thanks to the fact that multi-language support is being added, for now users of certain text encoding structures will have to create custom functions to get this to work properly. This is obviously a setback, but this will not affect the majority of web developers around the world.
Closing Comments
UCWords has much functionality to take advantage of. If you think you would like to give it a try, consider looking around for a specific tutorial with examples on coding practice.