PHP String Functions

PHP provides various string functions to access and manipulate strings. A list of important PHP string functions are given below.

1) PHP strtolower() function

The strtolower() function returns string in lowercase letter.

Syntax

Example

Output:

my name is khan

2) PHP strtoupper() function

The strtoupper() function returns string in uppercase letter.

Syntax

Example

Output:

MY NAME IS KHAN

3) PHP ucfirst() function

The ucfirst() function returns string converting first character into uppercase. It doesn’t change the case of other characters.

Syntax

Example

Output:

My name is KHAN

4) PHP lcfirst() function

The lcfirst() function returns string converting first character into lowercase. It doesn’t change the case of other characters.

Syntax

Example

Output:

mY name IS KHAN

5) PHP ucwords() function

The ucwords() function returns string converting first character of each word into uppercase.

Syntax

Example

Output:

My Name Is Sonoo Jaiswal

6) PHP strrev() function

The strrev() function returns reversed string.

Syntax

Example

Output:

lawsiaj oonoS si eman ym

7) PHP strlen() function

The strlen() function returns length of the string.

Syntax

Example

Output:

24
Please follow and like us:

Leave a Reply

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