function is a sub-routine or small program.which is design to perform to specific task.

Advantage of function

  • modular programming.
  • Reduction in the amount of work and development time.
  • Program and function debugging is easier.
  • Decision of work simplify due to use of devide and conqure principle.
  • Reduction of the program due to code reusebility.
  • Function can be accessed repeated without redevelopment.

Element/component of function

  • Function prototype or declearation
  • function parameters
  • function declarator or function defination
  • Function return
  • function call

Function may be define four method

  • No argument with No return
  • Argument with No return
  • No Argument with return
  • Argument with return

There are two type of function:-

Inbuilt function:-It is readyment function design by the software developer and It cannot edit by user.

Example in PHP

//Inbuilt Function
echo ucfirst("manish raj");//output Manish raj

echo ucwords("manish raj");//output Manish Raj


User defined function:-This function is define by user for for his own work and it can be change.

Example in PHP

// user define function declartion
function sum2no($no1,$no2){
	return ($no1+$no2);
// function calling
echo sum2no(2,4);


© 2014 Powered By