PHP Function definition within in a class
########################
PHP CODE
########################
<?php// function definition within in a class
class common
{
function addition($a,$b)
{
echo "<br/> Sum of the " . $a . " and " . $b . " is : " . ( $a + $b ) ;
}
function multiplication($a,$b)
{
echo "<br/> Multiplication of the " . $a . " and " . $b . " is : " . ( $a * $b ) ;
}
}
// function defination within in a class
// object creation for class
$com1 = new common();
// object creation for class
// function call via class's object
$com1->addition(2,3);
$com1->multiplication(2,3);
// function call via class's object
?>
########################
OUTPUT of the CODE
########################
Sum of the 2 and 3 is : 5
Multiplication of the 2 and 3 is : 6
Comments
Post a Comment