Function in PHP

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Functions are used to make the programming very easy .The code is written once in the function and whenever the code is required, the function is called by its name instead of writing the whole code again. This is the benift of using function.

in other word we can say, A Function is a reusable piece or block of code that performs a particular action. It takes input from the user in the form of parameters, performs certain actions, and gives the output.

There are two types o function :-

  1. Build in function
  2. User defined function

Build in function

Built in functions are predefined functions in PHP that exist in the installation package of php

ex:-

Web server with PHP - online presentation
example of build in function

User defined function

User-defined functions are those that are not available in the system. In user defined functions, the user can create the functions according to task perform. While the built-in functions have readymade functionality, you have to use the function. User Defined functions have also a lot of benefits.

SYNTAX

function functionName(){	
    code will be executed ;
}

ex :-

example of user defind function