Types of Functions in PHP

Notes:

Types of PHP Functions:
Any function created or defined in PHP will be of one of the below mentioned type
- A function without parameters and without return value
- A function with parameters and without return value
- A function without parameters and with return value
- A function with parameters and with return value

Creating different types of functions:
- A function without parameters and without return value:
Ex:
function wishHi()
{
echo "Hi", "<br/>";
}
wishHi();

- A function with parameters and without return value:
Ex:
function wish($message)
{
echo $message , "<br/>";
}
wish("good morning");
wish("good afternoon");

Ex:
function add($num1,$num2)
{
echo $num1 + $num2 , "<br/>";
}
add(2,2);

- A function with parameters and with return value:
Ex:
function add($num1,$num2)
{
return $num1 + $num2;
}
echo add(2,2), "<br/>";

Ex:
function square($num)
{
return $num*$num;
}
echo square(5);

- A function without parameters and with return value:
Ex:
function ValueOfPi()
{
return 3.142;
}
echo ValueOfPi(),"<br/>";

Interview Questions:

1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a