Logo


PHP Function Parameter



Parameters in Functions

Syntax

Function Function_Name([arg1 [, arg2 [, ... argN ]],]){
Function_Body
}


You can pass arguments to a function.
Parameters helps to pass informations/arguments into the function.
The arguments can be either numbers or strings.
Output of the function depends on the arguments you give it.


Example: 1

<?php
function test($sub)
{
echo 
$sub." Parameter <br />";
}
test("First ");
test("Second ");
?>

Output

First Parameter
Second Parameter

Example: 2

<?php
    
function test($sub)
     {
      echo 
$sub." Parameter <br />";
     }
       echo 
"I am ";
    
test("First ");
       echo 
"I am ";
    
test("Second ");
?>

Output

I am First Parameter
I am Second Parameter



If you like this Article, Share and Enjoy



See Also
Functions
Return Values of Function