The logical meaning of function is some particular task that
is the main working of a thing, that a thing performs some particular work. In
programming world some of the main workings of software are assembled in
particular functions. Functions are of
most importance in programming in any language whether php, java, Dot Net etc. Functions can be very simple like the addition
and subtraction with just few lines of code and they can be very long with vast
lines of codes. So the basic definition of function is Function is a block of
code that is used to perform some specific task.
Uses of functions are as follows
1)-By making functions we reduce the complexity of the
program.
2)-In functions we have blocked the code in function, and
that code can be reused again and again whenever that specific task need to be
performed, just by calling that function.
3)- It saves a lot of time in programming, and it reduces
the redundancy of code.
Examples of functions in php
<?php
Function addition ($a, $b)
{
$result = $a+$b;
Echo “addition result is”. $result;
}
Function subtraction($a, $b)
{
$result=$a-$b;
Echo “subtraction result is”. $result;
}
Function multiplication($a, $b)
{
$result=$a*$b;
Echo “multiplication result is”. $result;
}
Function division($a, $b)
{
$result=$a/$b;
Echo “division result is”. $result;
}
Function modulus($a, $b)
{
$result=$a%$b;
Echo “modulus result is”. $result;
}
addition (10,20);
subtraction (20,10);
multiplication (10,20);
division(20,10);
modulus(20,10);
?>
Output of above program will be as follows:-
Addition result is 30
Subtraction result is 10
Multiplication result is 200
Division result is 2
Modulus result is 0
The above program is a very simplest example of functions in
which we have created simple mathematical functions and whenever in a program
we require the mathematical calculation of two numbers we can simply call these
functions.
This example is provided by webcom technologies, webcom
technologies follow the easiest ways of explaining the concepts and problems.
Webcom deals in following technologies:-
1)-java
2)-Dot-Net
3)-php
4)-SAP
5)-Embedded
Webcom is the best industrial training institute that has
been in this market from the last 15 years and have very good record till now, to
find out the complete training solution in php, join Webcom Systems, Chandigarh.

No comments:
Post a Comment