Back to Top

How to Define and Call Case functions in PHP

Case functions in PHP

Today I come with some useful PHP functions which are very useful to understand case functions of PHP.

Case functions change the string from lowercase to uppercase and vice versa and those functions are strtolower,strtoupper, ucfirst and ucwords. strtolower function decapitalizes entire strings whereas strtoupper function capitalizes entire strings. Other case functions operate only on first letters of words which are.ucwords and ucfirst.

Lets checkout functions one by one:

1. strtolower():

The strtolower() function returns an all lowercase string. It doesn’t matter if the original is all uppercase or mixed,just returned string will be in lowercase.

Description

string strtolower (string str)

It returns the string with all alphabetic characters converted to lowercase.

Note that ‘alphabetic’ is determined by the current locale settings. This means that when “C” locale default characters such as umlaut-A will not be converted.

Lets see example:

OUTPUT

PHP is recursive acronym of hypertext preprocessor

strtolower() is extremely easy to use.you can decapitalize e-mail addresses contain capital letters.

2. strtoupper()

The strtoupper() function returns an all uppercase string, in spite of whether the original was all lowercase or mixed,It will capitalize the string.

OUTPUT:

PHP IS RECURSIVE ACRONYM OF HYPERTEXT PREPROCESSOR

3. ucfirst()

The ucfirst() function which capitalizes only the first character of a string.

OUTPUT

Php is recursive acronym of Hypertext Preprocessor

4. ucwords()

The ucwords() function capitalizes the first character of each word in a string:

OUTPUT

Php Is Recursive Acronym Of Hypertext Preprocessor

Neither ucwords() nor ucfirst() converts anything into lowercase. Each makes only the
appropriate significant characters into uppercase. If there are inappropriate capital characters in the middle of words, they will not be converted.

Do let me know case functions of PHP is useful to you. I would love to hear your opinions & experiences in the comments section below.

If you enjoyed reading this article, do share it your friends who are working in PHP.

Share:
Share on Facebook3

Share on LinkedIn1Tweet about this on TwitterShare on Google+0Buffer this pageDigg thisShare on Reddit0

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

Two years blogiversary

Posted on 3 years ago

Bhumi

How to Create a Custom WordPress Widget

Posted on 4 years ago

Bhumi

Angularjs 2 Tutorial for Beginners

Posted on 3 months ago

Bhumi

The Reader’s Poll – June 2015

Posted on 1 year ago

Bhumi

The Reader’s Poll – August 2014

Posted on 2 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 2 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 2 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 3 years ago

Bhumi