Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services.Php Functions and Passing parameter to function | Php tutorials Bestitworriors
Php Functions and Passing parameter to function
Php Functions and Passing parameter to function | Php tutorials Bestitworriors -Function are the block of combined statements that are written conbine and use repeately in the code.Function can be use multipute time in the code.Functon do not work untill call them.Function don't load with the page.Php functions also play a effective role in the code.You can perform different task in different way using functions.You can call same function to multiple time in the code
Some Key Points of PHP Functions
- Functions are block of code
- Functions work on calling the function name
- You can send parameters to the function
- Function work on multiple parameter
- Function also return the result or execute inside of function
Code
< ?php
function
printfun()
{
echo
"Hello Bestitworrior";
}
printfun(); // call
the
function
echo
"<br>";
function
Month($mname) {
echo
"Month Name is $mname <br>";
}
Month("January");
Month("Feburary");
Month("March");
Month("April");
echo
"<br>";
function
operation($value1,$value2,$op)
{
if ($op == '+')
{
$result = $value1 + $value2;
}
else if ($op == "*")
{
$result = $value1 * $value2;
}
else {
$result = 0;
}
return $result;
}
$ans = operation(2, 4, '+');
echo
"Addition of 2 and 4 is :".$ans;
echo
"<br>";
$ans1 = operation(2, 4, '*');
echo
"Multiplication of 2 and 4 is :".$ans1;
echo
"<br>";
? >
OutPut
Hello Bestitworrior
Month Name is January
Month Name is Feburary
Month Name is March
Month Name is April
Addition of 2 and 4 is :6
Multiplication of 2 and 4 is :8
Month Name is January
Month Name is Feburary
Month Name is March
Month Name is April
Addition of 2 and 4 is :6
Multiplication of 2 and 4 is :8
0 Comments