Php User-Defined with Example

Functions Definition

A function is a block of statements that can be used repeatedly in a program. A function is a piece of code which takes one more input in the form of parameter and does some processing and returns a value.

A function will not execute immediately when a page loads.

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

There are two types of functions:

User defined Functions

A user defined function declaration starts with the word function. Information can be passed to functions through arguments.

An arguments is just like a variable. Araguments are specified after the function name, inside the parentheses.

Functions reduces the repetition of code within a program

Syntax:



Example 1:


Result:


  Welcome to aimtocode!


Example 2:

Result:



  Today is Thrusday


Read in Details