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.