how to call php function code example
Example 1: php function
<html>
<head>
<title>Writing PHP Function with Parameters</title>
</head>
<body>
<?php
function addFunction($num1, $num2) {
$sum = $num1 + $num2;
echo "Sum of the two numbers is : $sum";
}
addFunction(10, 20);
?>
</body>
</html>
Example 2: php functions
#functions
<?php
function simpleFunction(){
echo 'Hello John';
}
simpleFunction();
function sayHello($name = " you out there!"){
echo "<br>and<br> Hello $name<br>";
}
sayHello('John');
sayHello();
function addNumbers($num1, $num2){
return $num1 + $num2;
}
echo addNumbers(2,3);
$myNum = 10;
function addFive($num){
$num += 5;
}
function addTen(&$num) {
$num += 10;
}
addFive($myNum);
echo "<br>Value: $myNum<br>";
addTen($myNum);
echo "Value: $myNum<br>";
?>