Friday, 6 February 2015

Function Parameter

As we see in precious example simple function example when we call that function its always do the same thing , what if we want to get dynamic values from functions? we use parameters with function,parameter also known as arguments.

Example:



<?php

// define custom function
function myfunction($myparameter) {
  
    echo $myparameter;

  
}
//call a function

myfunction("parameter1");

//each time its change value of function by pass argument
 
echo "<br/>";
myfunction("parameter2");
echo "<br/>";
myfunction("parameter3");
echo "<br/>";
myfunction("parameter4");
echo "<br/>";
myfunction("parameter5");
echo "<br/>";
//print output

parameter1
parameter2
parameter3
parameter4
parameter5
 ?>





This is also known as passing argument to function by value

No comments: