Information may be passed to functions via the argument list, which is a comma-delimited list of expressions. The arguments are evaluated from left to right, before the function is actually called (eager evaluation).
PHP supports passing arguments by value (the default), passing by reference, and default argument values. Variable-length argument lists and Named Arguments are also supported.
- Let’s understood by an example, concepts of simple parameter & argument.
File – code1.php
<?php // parameter is $v function amnt($v){ echo “amnt is: $v”; } // argument is 20 amnt(20); ?> |

- Let’s understood, calling method (function) & called method (function).
File – code2.php
<?php // body of called function ‘msg()’ function msg(){ echo ‘<br>2nd function msg()’; echo ‘<br>simple message!’; } // body of calling function ‘main()’ function main(){ echo ‘<br>1st function main()’; // called function ‘msg()’ msg(); } // calling function main(); ?> |

Let’s see another example…
File – code3.php
<?php function sum($a,$b){ return $a+$b; } function sub($a,$b){ return $a-$b; } function mul($a,$b){ return $a*$b; } function main(){ echo ‘sum is: ‘.sum(100,250); echo ‘<br>sub is: ‘.sub(100,50); echo ‘<br>mul is: ‘.mul(10,20); } main(); ?> |

- Let’s work with multiple different parameters (int, string, double)
File – code4.php
<?php /* parameter variables, works with different parameters U can define parameters datatypes a -> int, b-> string, c-> float */ function pluto(int $a,string $b,float $c){ echo “int a is: $a”; echo “<br>string b is: $b”; echo “<br>double C is: $c”; } // different arguments pluto(20,’microcodes’,75.5); ?> |

- Let’s make a code, which will takes three double values and returns summation of them as integer form. Perform different set of inputs 2 times.
File – code5.php
<?php function add($f1,$f2,$f3){ $add=$f1+$f2+$f3; print “addition double: $add”; return $add; } $sum = (int)add(10.2,23.4,40.5); echo “<br>addition integer: $sum”; ?> |
