What is Function in PHP | PHP Tutorial for Beginners to Advance Full Course | part 18

PHP functions are similar to other programming languages. 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.

 

Types of Function in PHP

  1. Pre-defined functions

  2. User defined functions

 

What is Pre Defined Function :

Predefined functions are the inbuilt functions of php. These functions can be subdivided into multiple categories as stated below. string functions. numeric functions. date and time functions

 

Example

print_r() , array() , include() , explode() ETC

 

 

What is User defined functions :

        User can define functions as per our requirements  These are called 'User Defined Function'.

 

Syntex :

      function keyword function_name(arg1,arg1,arg1) {

              //block of statement

              return value;

      }

 

Example :

.function sum($a,$b) {

        return $a+$b;

  }

Tutorial Topics