2. Simple Program Using Function
<?php
function salary($name, $salary)
{
echo "$name starting salary is $salary <br>";
}
salary("manisha",50000);
salary("manju",35000);
salary("nive",80000);
?>
Output:
manisha starting salary is 50000
manju starting salary is 35000
nive starting salary is 80000
3. Recursive Function To Print Fibbonacci Series
<?php
$a=-1;
$b=1;
$c=0;
function fib($n)
{
global $a, $b, $c;
if($n>0)
{
$c= $a+ $b;
$a= $b;
$b= $c;
echo " $c <br>";
fib($n-1);
}
}
echo "Printing Frist 10 Fibonacci series<br>";
fib(10);
?>
Output:
Printing Frist 10 Fibonacci series
0
1
1
2
3
5
8
13
21
34
4. Simple Program Using Default Function
<?php
functiondefault_fun($name,$dept="MCA")
{
echo "$name from $dept department <br> ";
}
default_fun("Manisha");
default_fun("Manju","EEE");
?>
Output:
Manisha from MCA department
Manju from EEE department
5. Checking the Century Year is leap or not
<?php
echo "Checking whether the century year is leap or not <br>";
function leap($year)
{
$n=$year%400;
switch($n)
{
case 0:
echo " $year is a leap year<br>";
break;
default:
echo " $year is not a leap year <br>";
}
}
leap(2000);
leap(3000);
?>
Output:
Checking whether the century year is leap or not
2000 is a leap year
3000 is not a leap year