PHP user defined function

I will show you how to use user defined functions in PHP.

user defined functions are used mostly to decrease the coding load.

Besides the built-in PHP functions, we can create our own functions.

A function is a block of statements that can be used repeatedly in a program.

A function will not execute immediately when a page loads.

A function will be executed by a call to the function.

A user defined function declaration starts with the word “function”:

we create a function named “premal()”. The opening curly brace ( { ) indicates the beginning of the function code and the closing curly brace ( } ) indicates the end of the function. The function outputs “premal katigar!”. To call the function, just write its name:


We have done user defined functions.

Changing the capitalization of stings

Making the string all capital letters:

You can simulate the CAPSLOCK key using thestrtoupper() PHP function.

Making the string all lower case letters:

You can also force all letters in a string to be lower case. This is done with the strtolower() PHP function.

Capitalizing each word:

You can choose to only capitalize the first letter of every word. This works great when working with a list of names or cities. This is done with theucwords() PHP function.

Code :


// using strtoupper() we can easily get all characters in capital.

echo strtoupper(“This is Premal Katigar”);


// using strtoupper() we can easily get all characters in capital.

echo strtolower(“This is Premal Katigar”);

// using ucwords() we can easily get all words with first character capitalized


capitalize all words

Output Of above code :

capitalized character output


Know More about php

Mail me your topic or problems

Contact : +91-84604-57306

How to Send email with WordPress

I will show you how to send mail to others using wordpress with your gmail account.

download wp smtp plugin.

here is link for free download :

Open it from Settings -> WP SMTP


WP SMTP Settings page opened :



Now write

select SSL authantication

SMTP port is 465


user name is your email.

password is your email