Aim: Write A Simple PHP Program To Demonstrate Use of Simple Function and
Aim: Write A Simple PHP Program To Demonstrate Use of Simple Function and
Aim: Write A Simple PHP Program To Demonstrate Use of Simple Function and
Experiment – 6
Title: Write a simple PHP program to demonstrate use of simple function
and parameterized function
Roll No.: 29 Name: Mehraan Khan
1. Aim: Write a simple PHP program to demonstrate use of simple function and
parameterized function
2. Requirements:
Personal Computer, Windows XP or above operating system, XAMPP (PHP,
APACHE, MYSQL), Microsoft Word
3. Theory:
Page 1 of 4
Page 2 of 4
Page 3 of 4
4. Program Code:
a. Write PHP script to calculate sum of two numbers with parameter and return value.
<?php
// Defining function
function getSum($num1, $num2){
$total = $num1 + $num2;
return $total;
}
// Printing returned value
echo "The Sum of Two Numbers :- ";
echo getSum(5, 10); // Outputs: 15
?>
b.Write PHP script to calculate cube of a number without parameter and return value.
<?php
function cube()
{
$no=8*8*8;
echo "The Cube without Parameter is:-";
echo $no;
}
cube();
?>
6. Conclusion: Hence we have learned write a simple PHP program to demonstrate use of
simple function and parameterized function.
Page 4 of 4